- 积分
- 30299
- 明经币
- 个
- 注册时间
- 2016-9-16
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
本帖最后由 fangmin723 于 2021-7-29 09:09 编辑
本帖转载于:AutoCAD.Net圆弧半径标注延长线 - 程序园 (voidcn.com)
- #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();
- }
- }
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?注册
x
评分
-
查看全部评分
|