0
我在AutoCAD 2017年開始開發具有.NET和我創建了下一個代碼基本矩形:如何從.NET創建一個簡單的AutoCad 2017維度?
[CommandMethod("AddSimpleRectangle")]
public static void AddSimpleRectangle()
{
var acDoc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
acDoc.LockDocument();
var acCurDb = acDoc.Database;
var pr = acDoc.Editor.GetPoint("\nEnter insertion point: ");
if (pr.Status != PromptStatus.OK)
return;
using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction())
{
var acBlkTbl = acTrans.GetObject(acCurDb.BlockTableId,
OpenMode.ForRead) as BlockTable;
var acBlkTblRec = acTrans.GetObject(acBlkTbl[BlockTableRecord.ModelSpace],
OpenMode.ForWrite) as BlockTableRecord;
using (var acPoly = new Polyline())
{
acPoly.AddVertexAt(0, new Point2d(pr.Value.X, pr.Value.Y), 0, 10, 10);
acPoly.AddVertexAt(1, new Point2d(pr.Value.X + 2000, pr.Value.Y), 0, 10, 10);
acPoly.AddVertexAt(2, new Point2d(pr.Value.X + 2000, pr.Value.Y + 500), 0, 10, 10);
acPoly.AddVertexAt(3, new Point2d(pr.Value.X, pr.Value.Y + 500), 0, 10, 10);
acPoly.Closed = true;
acPoly.Color = Autodesk.AutoCAD.Colors.Color.FromRgb(0, 125, 255);
acBlkTblRec.AppendEntity(acPoly);
acTrans.AddNewlyCreatedDBObject(acPoly, true);
}
acTrans.Commit();
}
}
現在,我需要追加在(比方說)一個維度中的一個側面表現出高度。 這怎麼可以從.NET完成? 謝謝!
非常感謝!但是,如果鎖被刪除,則會引發eLockViolation,儘管該命令未註冊爲會話命令標誌。 –