马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
- [CommandMethod("addrtd")]
- public static void MyAddRotatedDim()
- {
- Document doc = Application.DocumentManager.MdiActiveDocument;
- Editor ed = doc.Editor;
- Database db = doc.Database;
- Transaction tr = db.TransactionManager.StartTransaction();
- PromptPointResult psr1 = ed.GetPoint("\nFirst Point");
- if (psr1.Status != PromptStatus.OK) return;
- PromptPointResult psr2 = ed.GetPoint("\nSecond Point");
- if (psr2.Status != PromptStatus.OK) return;
- PromptPointResult psr3 = ed.GetPoint("\nLocation");
- if (psr3.Status != PromptStatus.OK) return;
- using (tr)
- {
- try
- {
- BlockTableRecord btr = (BlockTableRecord) tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite);
- Entity rd = AddRotatedDimension(psr1.Value, psr2.Value, psr3.Value) as Entity ;
-
- btr.AppendEntity(rd);
- tr.AddNewlyCreatedDBObject(rd, true);
- tr.Commit();
- }
- catch (Exception)
- {
- throw;
- }
- }
- }
- private static RotatedDimension AddRotatedDimension(Point3d p1, Point3d p2, Point3d p3)
- {
- Database db = Application.DocumentManager.MdiActiveDocument.Database;
- ObjectId dst = db.Dimstyle;
- Vector3d v = p1.GetVectorTo(p2);
- Vector2d nv = new Vector2d(v.X, v.Y);
- double an = nv.Angle;
- return new RotatedDimension(an, p1, p2, p3, "", dst);
- }
|