• AutoCAD.Net圆弧半径标注延长线


    #region 注册RegApp
            public static void CheckRegApp(string regapptablename)
            {            
                Database db = HostApplicationServices.WorkingDatabase;           
                using (Transaction trans = db.TransactionManager.StartTransaction())
                {        
    
                    RegAppTable appTbl = trans.GetObject(db.RegAppTableId,OpenMode.ForWrite) as RegAppTable;
                    if (!appTbl.Has(regapptablename))
                    {
                        RegAppTableRecord appTblRcd = new RegAppTableRecord();
                        appTblRcd.Name = regapptablename;
                        appTbl.Add(appTblRcd);
                        trans.AddNewlyCreatedDBObject(appTblRcd, true);
                    }
                    trans.Commit();
                }
                return ;
            }
            #endregion
    		
    		[CommandMethod("mydra")]
            public static void mydra()
            {
    
    
                // 获取当前数据库
                Document acDoc = Application.DocumentManager.MdiActiveDocument;
                Database acCurDb = acDoc.Database;
                // Start a transaction启动事务
                using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction())
                {
                    // Open the Block table for read以读模式打开块表
                    BlockTable acBlkTbl;
                    acBlkTbl = acTrans.GetObject(acCurDb.BlockTableId,
                    OpenMode.ForRead) as BlockTable;
                    // Open the Block table record Model space for write
                    // 以写模式打开块表记录ModelSpace
                    BlockTableRecord acBlkTblRec;
                    acBlkTblRec = acTrans.GetObject(acBlkTbl[BlockTableRecord.ModelSpace],
                    OpenMode.ForWrite) as BlockTableRecord;
                    // Create the radial dimension创建半径标注
                    RadialDimension acRadDim = new RadialDimension();
                    acRadDim.Center = new Point3d(0, 0, 0);
                    acRadDim.ChordPoint = new Point3d(5, 5, 0);
                    acRadDim.LeaderLength = 5;                
                    acRadDim.DimensionStyle = acCurDb.Dimstyle;
                    // 添加新对象到模型空间和事务                
                    CheckRegApp("ACAD_DSTYLE_DIMRADIAL_EXTENSION");//自定义函数检查RegApp名字是否存在,不存在就添加regApp名字
                    ResultBuffer resBuf = new ResultBuffer();
                    resBuf.Add(new TypedValue((int)DxfCode.ExtendedDataRegAppName, "ACAD_DSTYLE_DIMRADIAL_EXTENSION"));
                    resBuf.Add(new TypedValue((int)DxfCode.ExtendedDataInteger16, 387));
                    resBuf.Add(new TypedValue((int)DxfCode.ExtendedDataInteger16, 1));
                    resBuf.Add(new TypedValue((int)DxfCode.ExtendedDataInteger16, 388));
                    resBuf.Add(new TypedValue((int)DxfCode.ExtendedDataReal, 6.26953));//开始角度
                    resBuf.Add(new TypedValue((int)DxfCode.ExtendedDataInteger16, 390));
                    resBuf.Add(new TypedValue((int)DxfCode.ExtendedDataReal, 2.67146));//结束角度
                    acRadDim.XData = resBuf;
                    acBlkTblRec.AppendEntity(acRadDim);
                    acTrans.AddNewlyCreatedDBObject(acRadDim, true);
                    
                    // 提交修改,关闭事务
                    acTrans.Commit();
                }
            }
    

      

  • 相关阅读:
    第一篇:白话tornado源码之一个脚本引发的血案
    第二篇:白话tornado源码之待请求阶段
    Python 面向对象(初级篇)
    python 面向对象(进阶篇)
    Csharp启动exe文件
    UNIX时间戳
    JS日期格式化代码
    Android之什么是Activity和常用的ADB命令以及Android项目结构的认识
    thread同步测试
    Fluent NHibernate使用小结:(1)通用配置文件创建方法
  • 原文地址:https://www.cnblogs.com/edata/p/9193389.html
Copyright © 2020-2023  润新知