#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(); ???????????} ???????}
AutoCAD.Net圆弧半径标注延长线
原文地址:https://www.cnblogs.com/edata/p/9193389.html