static public void DoIt() { Editor ed = Application.DocumentManager.MdiActiveDocument.Editor; PromptPointOptions opts = new PromptPointOptions("\nEnter Ellipse Center Point:"); PromptPointResult res = ed.GetPoint(opts); Vector3d x = Application.DocumentManager.MdiActiveDocument.Database.Ucsxdir; Vector3d y = Application.DocumentManager.MdiActiveDocument.Database.Ucsydir; Vector3d NormalVec = x.CrossProduct(y); Database db = Application.DocumentManager.MdiActiveDocument.Database; Autodesk.AutoCAD.DatabaseServices.TransactionManager tm = db.TransactionManager; //Create Ellipsejig EllipseJig jig = new EllipseJig(res.Value, NormalVec.GetNormal()); //first call drag to get the major axis jig.setPromptCounter(0); Application.DocumentManager.MdiActiveDocument.Editor.Drag(jig); // Again call drag to get minor axis jig.setPromptCounter(1); Application.DocumentManager.MdiActiveDocument.Editor.Drag(jig); //Append entity. using (Transaction myT = tm.StartTransaction()) { BlockTable bt = (BlockTable)tm.GetObject(db.BlockTableId, OpenMode.ForRead, false); BlockTableRecord btr = (BlockTableRecord)tm.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite, false); btr.AppendEntity(jig.GetEntity()); tm.AddNewlyCreatedDBObject(jig.GetEntity(), true); myT.Commit(); } }
public static void DoIt() { Editor ed = Application.DocumentManager.MdiActiveDocument.Editor; PromptPointOptions opts = new PromptPointOptions("\nEnter Ellipse Center Point:"); PromptPointResult res = ed.GetPoint(opts); Vector3d x = Application.DocumentManager.MdiActiveDocument.Database.Ucsxdir; Vector3d y = Application.DocumentManager.MdiActiveDocument.Database.Ucsydir; Vector3d NormalVec = x.CrossProduct(y); Database db = Application.DocumentManager.MdiActiveDocument.Database; Autodesk.AutoCAD.DatabaseServices.TransactionManager tm = db.TransactionManager; //Create Ellipsejig EllipseJig jig = new EllipseJig(res.Value,NormalVec.GetNormal()); //first call drag to get the major axis jig.setPromptCounter(0); Application.DocumentManager.MdiActiveDocument.Editor.Drag(jig); // Again call drag to get minor axis jig.setPromptCounter(1); Application.DocumentManager.MdiActiveDocument.Editor.Drag(jig); //Append entity. using (Transaction myT = tm.StartTransaction()) { BlockTable bt = (BlockTable)tm.GetObject(db.BlockTableId,OpenMode.ForRead,false); BlockTableRecord btr = (BlockTableRecord)tm.GetObject(bt[BlockTableRecord.ModelSpace],OpenMode.ForWrite,false); btr.AppendEntity(jig.GetEntity()); tm.AddNewlyCreatedDBObject(jig.GetEntity(),true); myT.Commit(); } }