AutoCad 二次开发 .net 之相同块的自动编号







using System;
using System.Collections.Generic;
using System.Linq;
using System.Text; using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.Geometry; namespace MulitySortNum
{
public class SortNum
{
private Document doc = Application.DocumentManager.MdiActiveDocument;
private Database db = Application.DocumentManager.MdiActiveDocument.Database;
private Editor ed = Application.DocumentManager.MdiActiveDocument.Editor; private string str = "LL";
public int index = ; [CommandMethod("NumSort1")]
public void NumSort1()
{
index = ; var propEnt = new PromptEntityOptions("请选择要编号的一个块\n"); var propRes = ed.GetEntity(propEnt); if (propRes.Status != PromptStatus.OK)
{
return;
} var oId = propRes.ObjectId; ObjectIdCollection objIds = null;
List<DBText> listDBText = new List<DBText>(); using (Transaction trans = db.TransactionManager.StartTransaction())
{
var blkRef = trans.GetObject(oId, OpenMode.ForRead) as BlockReference; if (blkRef == null)
{
Application.ShowAlertDialog("请选择块定义");
return;
} var recId = blkRef.BlockTableRecord; var blkTblRec = trans.GetObject(recId, OpenMode.ForRead) as BlockTableRecord; objIds = blkTblRec.GetBlockReferenceIds(true, false); var txtStlTbl = trans.GetObject(db.TextStyleTableId, OpenMode.ForRead) as TextStyleTable; var txtstyleId = txtStlTbl["Standard"]; List<BlockReference> listBr = new List<BlockReference>(); foreach (ObjectId objectId in objIds)
{
var blkTempRef = trans.GetObject(objectId, OpenMode.ForRead) as BlockReference; listBr.Add(blkTempRef); } listBr.OrderByDescending(b => b.Position.Y).ToList().ForEach(blkTempRef =>
{ DBText dbText = new DBText();
dbText.TextString = str + "_" + index++;
dbText.TextStyleId = txtstyleId; var pointMin = blkTempRef.Bounds.Value.MinPoint;
var pointMax = blkTempRef.Bounds.Value.MaxPoint;
dbText.HorizontalMode = TextHorizontalMode.TextMid;
dbText.AlignmentPoint = pointMin + Vector3d.YAxis * + Vector3d.XAxis * Math.Abs(pointMax.X - pointMin.X) / ; listDBText.Add(dbText); }); trans.Commit();
} listDBText.ToSpace(); }
}
}
AutoCad 二次开发 .net 之相同块的自动编号的更多相关文章
- AutoCad 二次开发 .net 之层表的增加 删除 修改图层颜色 遍历 设置当前层
AutoCad 二次开发 .net 之层表的增加 删除 修改图层颜色 遍历 设置当前层 AutoCad 二次开发 .net 之层表的增加 删除 修改图层颜色 遍历 设置当前层我理解的图层的作用大概是把 ...
- AutoCad 二次开发 文字镜像
AutoCad 二次开发 文字镜像 参考:https://adndevblog.typepad.com/autocad/2013/10/mirroring-a-dbtext-entity.html 在 ...
- AutoCAD二次开发——AutoCAD.NET API开发环境搭建
AutoCAD二次开发工具:1986年AutoLisp,1989年ADS,1990年DCL,1993年ADS-RX,1995年ObjectARX,1996年Active X Automation(CO ...
- 1,下载和部署开发环境--AutoCAD二次开发
环境需求为: AutoCAD 2020版 ObjectARX SDK 下载地址:https://www.autodesk.com/developer-network/platform-technolo ...
- AutoCad 二次开发 jig操作之标注跟随线移动
AutoCad 二次开发 jig操作之标注跟随线移动 在autocad当中,我认为的jig操作的意思就是即时绘图的意思,它能够实时的显示出当前的操作,以便我们直观的感受到当前的绘图操作是什么样子会有什 ...
- AutoCAD二次开发-使用ObjectARX向导创建应用程序(HelloWorld例子)
AutoCAD2007+vs2005 首先自己去网上搜索下载AutoCAD2007的ARX开发包. 解压后如下 打开后如下 classmap文件夹为C++类和.net类的框架图,是一个DWG文件. d ...
- 我的AutoCAD二次开发之路 (一)
原帖地址 http://379910987.blog.163.com/blog/static/33523797201011184552167/ 今天在改代码的时候,遇到了AddVertexAt方法的用 ...
- Autocad中使用命令来调用python对Autocad二次开发打包后的exe程序
在Autocad中直接调用Python二次开发程序是有必要的,下面介绍一种方法来实现这个功能: 其基本思路是:先将二次开发的程序打包为可执行程序exe,然后编写lsp文件,该文件写入调用exe程序的语 ...
- 承接 AutoCAD 二次开发 项目
本人有多年的CAD开发经验,独立完成多个CAD二次开发项目.熟悉.net及Asp.net开发技术,和Lisp开发技术. 现在成立了工作室,独立承接CAD二次开发项目.结项后提供源码及开发文档,有需要的 ...
随机推荐
- MongoDB 学习笔记之 Aggregation Pipeline实战实现inner join
Aggregation Pipeline实战实现inner join: leftT集合: comments集合: 现在我们要用aggregation实现inner join db.comments. ...
- Redis开发与运维:linux安装
Linux 安装 我的系统是inux 系统,官网下载 https://redis.io/download redis-5.0.5.tar.gz 解压: 编译安装: 官网和文档说得已经很清楚了,现在就执 ...
- vue- Vue-Cli脚手架工具安装 -创建项目-页面开发流程-组件生命周期- -03
目录 Vue-Cli 项目环境搭建 与 python 基础环境对比 环境搭建 创建启动 vue 项目 命令创建项目(步骤小多) 启动 vue 项目(命令行方式) 启动 vue 项目(pycharm 方 ...
- Spring框架学习笔记(4)——SSM整合以及创建Maven自定义模版
Spring+Spring MVC+MyBatis+Maven SSM整合的核心还是Spring+MyBatis的整合,回顾一下MyBatis操作数据库流程,我们是使用一个SQLSessionFact ...
- java中的Math.ceil、Math.floor和Math.round
ceil意为天花板,指向上取整:floor意为地板,指向下取整:round指四舍五入 package com.company; public class Main { public static vo ...
- spring boot项目下application.properties中使用logging.path和logging.file时的细节
logging.path仅仅用于指定日志输出的目录,且不能指定输出的文件名,且默认名为spring.log 若指定的是相对目录,则会生成在当前总项目的目录下 idea中新建sprnig boot项目 ...
- 第三方登录之GitHub篇
第一步,准备工作.获取Client ID和Client Secret 1.自行登陆GitHub官网,点击Setting,如下图: 2.继续,点击Developer settings,如下图: 3.继续 ...
- flask 源码解析:上下文(一)
文章出处 https://www.cnblogs.com/jackchengcc/archive/2018/11/29/10025949.html 一:什么是上下文 每一段程序都有很多外部变量.只有 ...
- 一篇文章教会你jQuery应用
一 认识jQuery jQuery是JavaScript Query的缩写形式.jQuery是一款非常优秀的JavaScript库,即便是MVVM框架盛行的今天,也有超过半数的网页及应用直接或间接的使 ...
- kali系统
打开终端分别输入下面两条命令: update-alternatives --install /usr/bin/python python /usr/bin/python2 100 update-alt ...