zoukankan      html  css  js  c++  java
  • 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();
                }
            }
    

      

  • 相关阅读:
    《深入理解C#》泛型高级
    vs2019 插件下载慢的解决方法
    C# Tuple和 ValueTuple
    前端ajax用json方式请求 后端php 用 $GLOBALS['HTTP_RAW_POST_DATA'] 取值
    Vue之Axios跨域问题解决方案
    Jquery自定义方法获取URL后面参数
    C# List 某行数据置顶
    EF空字段使用contains查询的解决办法
    sql语句查询,多字段like模糊查询优化
    Asp.Net Core中间件
  • 原文地址:https://www.cnblogs.com/edata/p/9193389.html
Copyright © 2011-2022 走看看