addPoly3d(this List <Point3d> pnt3ds, string nameLayer = "0", short color = 256) { ObjectId idPoly3d = ObjectId.Null; Polyline3d poly3d = new Polyline3d(); try { using (Transaction tr = BaseObjs.startTransactionDb()) { BlockTable bt = (BlockTable)BaseObjs._db.BlockTableId.GetObject(OpenMode.ForRead); BlockTableRecord MS = (BlockTableRecord)bt[BlockTableRecord.ModelSpace].GetObject(OpenMode.ForWrite); idPoly3d = MS.AppendEntity(poly3d); tr.AddNewlyCreatedDBObject(poly3d, true); poly3d.SetDatabaseDefaults(); Layer.manageLayers(nameLayer); poly3d.Layer = nameLayer; poly3d.Color = Color.FromColorIndex(ColorMethod.ByBlock, color); foreach (Point3d pnt3d in pnt3ds) { PolylineVertex3d poly3dVertex = new PolylineVertex3d(pnt3d); poly3d.AppendVertex(poly3dVertex); tr.AddNewlyCreatedDBObject(poly3dVertex, true); } tr.Commit(); }// end using } catch (System.Exception ex) { BaseObjs.writeDebug(ex.Message + " Draw.cs: line: 406"); } return(idPoly3d); }
addLdr(Point3dCollection pnt3ds, ObjectId idLayer, double sizeArrow, double sizeGap, Color color, ObjectId idMTxt, string nameStyle = "Annotative", bool spline = false) { ObjectId idLdr = ObjectId.Null; Leader ldr = new Leader(); try { using (Transaction tr = BaseObjs.startTransactionDb()) { BlockTable BT = Blocks.getBlockTable(); BlockTableRecord MS = (BlockTableRecord)tr.GetObject(BT[BlockTableRecord.ModelSpace], OpenMode.ForWrite); ObjectId idDimStyle = Dim.getDimStyleTableRecord("Annotative"); DimStyleTableRecord dstr = (DimStyleTableRecord)tr.GetObject(idDimStyle, OpenMode.ForRead); ldr.SetDatabaseDefaults(); ldr.HasArrowHead = true; ldr.DimensionStyle = idDimStyle; ldr.SetDimstyleData(dstr); ldr.LayerId = idLayer; ldr.Dimasz = sizeArrow; ldr.Dimgap = sizeGap; ldr.IsSplined = spline; ldr.Color = color; ldr.Annotative = AnnotativeStates.True; for (int i = 0; i < pnt3ds.Count; i++) { try { ldr.AppendVertex(pnt3ds[i]); } catch (System.Exception ex) { BaseObjs.writeDebug(ex.Message + " Ldr.cs: line: 60"); } } idLdr = MS.AppendEntity(ldr); tr.AddNewlyCreatedDBObject(ldr, true); if (!idMTxt.IsNull) { ldr.Annotative = AnnotativeStates.True; ldr.Annotation = idMTxt; ldr.Dimtad = 0; ldr.EvaluateLeader(); } tr.Commit(); }// end using } catch (System.Exception ex) { BaseObjs.writeDebug(ex.Message + " Ldr.cs: line: 79"); } return(idLdr); }
getXRefTinSurface(ObjectId idbr, string nameSurf) { TinSurface s = null; try { using (Transaction tr = BaseObjs.startTransactionDb()) { BlockReference br = (BlockReference)tr.GetObject(idbr, OpenMode.ForRead); ObjectId idbtr = br.BlockTableRecord; BlockTableRecord btr = (BlockTableRecord)idbtr.GetObject(OpenMode.ForRead); foreach (ObjectId idObj in btr) { Entity ent = (Entity)tr.GetObject(idObj, OpenMode.ForRead); if (ent is TinSurface) { s = (TinSurface)ent; if (s.Name == nameSurf) { break; } } } tr.Commit(); } } catch (System.Exception ex) { BaseObjs.writeDebug(ex.Message + " xRef.cs: line: 1203"); } return(s); }
poly3d_pnt3dColl(Polyline3d poly3d) { Point3dCollection pnts3d = new Point3dCollection(); try { using (Transaction tr = BaseObjs.startTransactionDb()) { foreach (ObjectId objID in poly3d) { PolylineVertex3d v3d = (PolylineVertex3d)tr.GetObject(objID, OpenMode.ForRead); Point3d pnt3d = new Point3d(); pnt3d = v3d.Position; pnts3d.Add(pnt3d); } tr.Commit(); } } catch (System.Exception ex) { BaseObjs.writeDebug(ex.Message + " Conv.cs: line: 521"); } return(pnts3d); }
selectEntity(System.Type classType, string message, string reject, out Point3d pnt3dPicked, out PromptStatus ps) { Entity ent = null; BaseObjs.acadActivate(); PromptEntityOptions peos = new PromptEntityOptions(message); peos.SetRejectMessage(reject); peos.AddAllowedClass(classType, true); peos.AllowNone = true; PromptEntityResult per = BaseObjs._editor.GetEntity(peos); pnt3dPicked = per.PickedPoint; ps = per.Status; switch (ps) { case PromptStatus.OK: try { using (Transaction tr = BaseObjs.startTransactionDb()) { ent = (Entity)tr.GetObject(per.ObjectId, OpenMode.ForRead); tr.Commit(); } } catch (System.Exception ex) { BaseObjs.writeDebug(ex.Message + " Select.cs: line: 599"); } break; } return(ent); }
getSegProps(ObjectId idPoly) { List <SEG_PROP> props = new List <SEG_PROP>(); try { using (Transaction tr = BaseObjs.startTransactionDb()) { Polyline poly = (Polyline)tr.GetObject(idPoly, OpenMode.ForRead); for (int i = 1; i < poly.NumberOfVertices; i++) { Point2d pnt2d0 = poly.GetPoint2dAt(i - 1); Point2d pnt2d1 = poly.GetPoint2dAt(i - 0); SEG_PROP prop = new SEG_PROP(); prop.LENGTH = Geom.get2dDistance(pnt2d0, pnt2d1); prop.DIR_AHEAD = Measure.getAzRadians(pnt2d0, pnt2d1); props.Add(prop); } tr.Commit(); } } catch (System.Exception ex) { BaseObjs.writeDebug(ex.Message + " Misc.cs: line: 815"); } return(props); }
TranslateCoordinates(Point3dCollection pnts3d, Point3d pnt3dBase, double angle) { Point3dCollection pnts3dTrans = null; try { using (Transaction tr = BaseObjs.startTransactionDb()) { pnts3dTrans = new Point3dCollection(); // Translate the OCS to WCS Matrix3d matrx3d = BaseObjs._editor.CurrentUserCoordinateSystem; CoordinateSystem3d coordSys = matrx3d.CoordinateSystem3d; foreach (Point3d pnt3d in pnts3d) { pnts3dTrans.Add(pnt3d.TransformBy(Matrix3d.Rotation(angle, coordSys.Zaxis, pnt3dBase))); } // Save the new objects to the database tr.Commit(); } } catch (System.Exception ex) { BaseObjs.writeDebug(ex.Message + " UCsys.cs: line: 379"); } return(pnts3dTrans); }
addTable(Point3d pnt3dIns, int rows, int cols, double rowHeight, double colWidth) { ObjectId idTable = ObjectId.Null; Table table = new Table(); table.TableStyle = BaseObjs._db.Tablestyle; table.SetSize(rows, cols); foreach (Row row in table.Rows) { row.Height = rowHeight; } foreach (Column col in table.Columns) { col.Width = colWidth; } using (Transaction tr = BaseObjs.startTransactionDb()) { BlockTable bt = (BlockTable)tr.GetObject(BaseObjs._db.BlockTableId, OpenMode.ForRead); BlockTableRecord btr = (BlockTableRecord)tr.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite); idTable = btr.AppendEntity(table); tr.AddNewlyCreatedDBObject(table, true); tr.Commit(); } return(idTable); }
addCircle(Point3d pntCEN, double RADIUS, string nameLayer = "0", short color = 256) { ObjectId id = ObjectId.Null; Circle circle = new Circle(); try { using (Transaction tr = BaseObjs.startTransactionDb()) { BlockTableRecord MS = Blocks.getBlockTableRecordMS(); circle.SetDatabaseDefaults(); circle.Center = pntCEN; circle.Radius = RADIUS; Layer.manageLayers(nameLayer); circle.Layer = nameLayer; circle.Color = Color.FromColorIndex(ColorMethod.ByBlock, color); id = MS.AppendEntity(circle); tr.AddNewlyCreatedDBObject(circle, true); tr.Commit(); }// end using } catch (System.Exception ex) { BaseObjs.writeDebug(ex.Message + " Draw.cs: line: 116"); } return(id); }
addPolyFromPoly3d(ObjectId idPoly3d, string nameLayer = "0") { ObjectId idPoly = ObjectId.Null; Polyline poly = new Polyline(); Layer.manageLayers(nameLayer); poly.Layer = nameLayer; try { using (Transaction tr = BaseObjs.startTransactionDb()) { BlockTableRecord MS = Blocks.getBlockTableRecordMS(); int i = -1; poly.SetDatabaseDefaults(); foreach (Point3d pnt3d in idPoly3d.getCoordinates3d()) { i = ++i; Point2d pnt2d = new Point2d(pnt3d.X, pnt3d.Y); poly.AddVertexAt(i, pnt2d, 0, 0, 0); } idPoly = MS.AppendEntity(poly); tr.AddNewlyCreatedDBObject(poly, true); tr.Commit(); }// end using } catch (System.Exception ex) { BaseObjs.writeDebug(ex.Message + " Draw.cs: line: 606"); } return(idPoly); }
addPolyOffset(ObjectId idPoly, double dist, string nameLayer = "0") { ObjectId idEnt = ObjectId.Null; Layer.manageLayers(nameLayer); try { using (Transaction tr = BaseObjs.startTransactionDb()) { BlockTableRecord btrMS = Base_Tools45.Blocks.getBlockTableRecordMS(); Polyline poly = (Polyline)tr.GetObject(idPoly, OpenMode.ForRead); DBObjectCollection dbObjColl = poly.GetOffsetCurves(dist); foreach (Entity ent in dbObjColl) { ent.Layer = nameLayer; idEnt = btrMS.AppendEntity(ent); tr.AddNewlyCreatedDBObject(ent, true); } tr.Commit(); } } catch (System.Exception ex) { BaseObjs.writeDebug(ex.Message + " Draw.cs: line: 657"); } return(idEnt); }
addPoly3d(Point3dCollection pnt3ds, string nameLayer) { ObjectId idPoly3d = ObjectId.Null; try { using (Transaction tr = BaseObjs.startTransactionDb()) { try { BlockTableRecord MS = Blocks.getBlockTableRecordMS(); Polyline3d poly3d = new Polyline3d(Poly3dType.SimplePoly, pnt3ds, false); Layer.manageLayers(nameLayer); poly3d.Layer = nameLayer; idPoly3d = MS.AppendEntity(poly3d); tr.AddNewlyCreatedDBObject(poly3d, true); tr.Commit(); } catch (System.Exception ex) { BaseObjs.writeDebug(ex.Message + " Draw.cs: line: 561"); } }// end using } catch (System.Exception ex) { BaseObjs.writeDebug(ex.Message + " Draw.cs: line: 567"); } return(idPoly3d); }
addPoly3d(Point3dCollection pnt3ds, string nameLayer = "0", short color = 256, LineWeight weight = LineWeight.ByLayer) { ObjectId idPoly3d = ObjectId.Null; Polyline3d poly3d = null; try { using (BaseObjs._acadDoc.LockDocument()) { BaseObjs._transactionManagerDoc.EnableGraphicsFlush(true); using (Transaction tr = BaseObjs.startTransactionDb()) { BlockTableRecord MS = Blocks.getBlockTableRecordMS(); poly3d = new Polyline3d(Poly3dType.SimplePoly, pnt3ds, false); Layer.manageLayers(nameLayer); poly3d.Layer = nameLayer; poly3d.Color = Color.FromColorIndex(ColorMethod.ByLayer, color); poly3d.LineWeight = weight; idPoly3d = MS.AppendEntity(poly3d); tr.AddNewlyCreatedDBObject(poly3d, true); tr.Commit(); }// end using } } catch (System.Exception ex) { BaseObjs.writeDebug(ex.Message + " Draw.cs: line: 477"); } return(idPoly3d); }
addPoly3d(Point3d[] pnt3ds, string nameLayer = "0", short color = 256) { ObjectId idPoly3d = ObjectId.Null; Polyline3d poly3d = new Polyline3d(); try { using (Transaction tr = BaseObjs.startTransactionDb()) { BlockTableRecord MS = Blocks.getBlockTableRecordMS(); idPoly3d = MS.AppendEntity(poly3d); tr.AddNewlyCreatedDBObject(poly3d, true); int i = -1; poly3d.SetDatabaseDefaults(); Layer.manageLayers(nameLayer); poly3d.Layer = nameLayer; poly3d.Color = Color.FromColorIndex(ColorMethod.ByBlock, color); foreach (Point3d pnt3d in pnt3ds) { i = ++i; PolylineVertex3d poly3dVertex = new PolylineVertex3d(pnt3d); poly3d.AppendVertex(poly3dVertex); tr.AddNewlyCreatedDBObject(poly3dVertex, true); } tr.Commit(); }// end using } catch (System.Exception ex) { BaseObjs.writeDebug(ex.Message + " Draw.cs: line: 443"); } return(idPoly3d); }
deleteObjs(ObjectId[] ids) { try { using (Transaction tr = BaseObjs.startTransactionDb()) { foreach (ObjectId idObj in ids) { try { Entity ENT = (Entity)idObj.GetObject(OpenMode.ForWrite); ENT.Erase(); } catch (System.Exception ex) { BaseObjs.writeDebug(ex.Message + " Misc.cs: line: 503"); } } tr.Commit(); } // end using } catch (System.Exception ex) { BaseObjs.writeDebug(ex.Message + " Misc.cs: line: 511"); } }
addBtr(string strName) { Database DB = BaseObjs._db; BlockTableRecord Btr = null; try { using (Transaction tr = BaseObjs.startTransactionDb()) { BlockTable BT = (BlockTable)DB.BlockTableId.GetObject(OpenMode.ForWrite); Btr = new BlockTableRecord(); Btr.Name = strName; Btr.Origin = Pub.pnt3dO; BT.Add(Btr); tr.AddNewlyCreatedDBObject(Btr, true); tr.Commit(); }// end using } catch (System.Exception ex) { BaseObjs.writeDebug(ex.Message + " Blocks.cs: line: 497"); } return(Btr); }
getObjectIdFromHandle(string strHandle) { ObjectId ID = ObjectId.Null; Database DB = BaseObjs._db; // Convert hexadecimal string to 64-bit integer long LN = Convert.ToInt64(strHandle, 16); // Not create a Handle from the long integer Handle HN = new Handle(LN); try { using (Transaction tr = BaseObjs.startTransactionDb()) { // And attempt to get an ObjectId for the Handle ID = DB.GetObjectId(false, HN, 0); tr.Dispose(); } } catch (System.Exception ex) { BaseObjs.writeDebug(ex.Message + " Misc.cs: line: 631"); } return(ID); }
getBlockRefAttributeValue(ObjectId idBR, string nameAttribute) { string value = string.Empty; try { using (Transaction tr = BaseObjs.startTransactionDb()) { BlockReference br = (BlockReference)tr.GetObject(idBR, OpenMode.ForRead); foreach (ObjectId idAR in br.AttributeCollection) { Autodesk.AutoCAD.DatabaseServices.DBObject obj = tr.GetObject(idAR, OpenMode.ForRead); AttributeReference ar = (AttributeReference)obj; if (ar != null) { if (ar.Tag.ToUpper() == nameAttribute.ToUpper()) { value = ar.TextString; } } } } } catch (System.Exception ex) { BaseObjs.writeDebug(ex.Message + " Blocks.cs: line: 711"); } return(value); }
addUcsTableRecord(string name) { ObjectId id = ObjectId.Null; UcsTableRecord Ucstr = new UcsTableRecord(); try { using (Transaction tr = BaseObjs.startTransactionDb()) { UcsTable UcsT = getUcsTable(); try { Ucstr.Name = name; UcsT.Add(Ucstr); tr.AddNewlyCreatedDBObject(Ucstr, true); } catch (System.Exception ex) { BaseObjs.writeDebug(ex.Message + " UCsys.cs: line: 177"); } tr.Commit(); id = Ucstr.ObjectId; } } catch (System.Exception ex) { BaseObjs.writeDebug(ex.Message + " UCsys.cs: line: 185"); } return(id); }
getDimStyleTableRecord(string name) { ObjectId id = ObjectId.Null; try { using (Transaction tr = BaseObjs.startTransactionDb()) { DimStyleTable dst = (DimStyleTable)HostApplicationServices.WorkingDatabase.DimStyleTableId.GetObject(OpenMode.ForRead); if (dst.Has(name) == true) { //dst.UpgradeOpen(); DimStyleTableRecord dstr = (DimStyleTableRecord)dst[name].GetObject(OpenMode.ForRead); id = dstr.ObjectId; } else { dst.UpgradeOpen(); DimStyleTableRecord dstr = new DimStyleTableRecord(); dstr.Name = name; dstr.Annotative = AnnotativeStates.True; id = dst.Add(dstr); tr.AddNewlyCreatedDBObject(dstr, true); } tr.Commit(); } } catch (System.Exception ex) { BaseObjs.writeDebug(ex.Message + " Dim.cs: line: 162"); } return(id); }
poly_ArcsLines(this ObjectId idPoly, string nameLayer) { List <ObjectId> ids = new List <ObjectId>(); using (var tr = BaseObjs.startTransactionDb()){ Polyline poly = (Polyline)tr.GetObject(idPoly, OpenMode.ForWrite); for (int i = 1; i < poly.NumberOfVertices; i++) { double bulge = poly.GetBulgeAt(i - 1); if (bulge == 0) { ObjectId id = Draw.addLine(poly.GetPoint3dAt(i - 1), poly.GetPoint3dAt(i), nameLayer); id.changeProp(clr.red); BaseObjs.updateGraphics(); ids.Add(id); } else { ObjectId id = Draw.addArc(poly.GetPoint3dAt(i - 1), poly.GetPoint3dAt(i), bulge, nameLayer); id.changeProp(clr.red); BaseObjs.updateGraphics(); ids.Add(id); } } tr.Commit(); } return(ids); }
removeDuplicateVertex(Polyline poly) { Point2d pnt2d0; Point2d pnt2dX; try { using (Transaction tr = BaseObjs.startTransactionDb()) { for (int i = 1; i < poly.NumberOfVertices; i++) { pnt2d0 = poly.GetPoint2dAt(i - 1); pnt2dX = poly.GetPoint2dAt(i - 0); if (pnt2d0.X == pnt2dX.X && pnt2d0.Y == pnt2dX.Y) { poly.RemoveVertexAt(i); } } tr.Commit(); } } catch (System.Exception ex) { BaseObjs.writeDebug(ex.Message + " Misc.cs: line: 1061"); } }
selectEntity(string message, out bool escape) { escape = false; Entity ent = null; BaseObjs.acadActivate(); PromptEntityOptions peos = new PromptEntityOptions(message); peos.AllowNone = false; PromptEntityResult per = BaseObjs._editor.GetEntity(peos); if (per.Status == PromptStatus.OK) { using (Transaction tr = BaseObjs.startTransactionDb()) { ent = (Entity)tr.GetObject(per.ObjectId, OpenMode.ForRead); tr.Commit(); } } else { escape = true; } return(ent); }
ForEach <T>(Action <T> action) where T : Entity { try { using (var tr = BaseObjs.startTransactionDb()) { var blockTable = (BlockTable)tr.GetObject(BaseObjs._db.BlockTableId, OpenMode.ForRead); var modelSpace = (BlockTableRecord)tr.GetObject(blockTable[BlockTableRecord.ModelSpace], OpenMode.ForRead); RXClass theClass = RXObject.GetClass(typeof(T)); foreach (ObjectId id in modelSpace) { if (id.ObjectClass.IsDerivedFrom(theClass)) { try { var ent = (T)tr.GetObject(id, OpenMode.ForRead); action(ent); } catch (System.Exception ex) { BaseObjs.writeDebug(ex.Message + " Misc.cs: line: 1312"); } } } tr.Commit(); } } catch (System.Exception ex) { BaseObjs.writeDebug(ex.Message + " Misc.cs: line: 1321"); } }
selectEntity(string message, string reject, out bool escape) { escape = true; ObjectId idEnt = ObjectId.Null; BaseObjs.acadActivate(); PromptEntityOptions PEOS = new PromptEntityOptions(message); PEOS.SetRejectMessage(reject); PEOS.AddAllowedClass(typeof(Line), true); PEOS.AddAllowedClass(typeof(Arc), true); PEOS.AddAllowedClass(typeof(Polyline), true); PEOS.AllowNone = false; PromptEntityResult PER = BaseObjs._editor.GetEntity(PEOS); if (PER.Status == PromptStatus.OK) { try { using (Transaction tr = BaseObjs.startTransactionDb()) { Entity ENT = (Entity)tr.GetObject(PER.ObjectId, OpenMode.ForRead); idEnt = ENT.ObjectId; escape = false; tr.Commit(); } } catch (System.Exception ex) { BaseObjs.writeDebug(ex.Message + " Select.cs: line: 635"); } } return(idEnt); }
deleteObjs(TypedValue[] TVs, Point3d pnt3dLL, Point3d pnt3dUR) { ObjectId[] ids; SelectionFilter filter = new SelectionFilter(TVs); PromptSelectionResult PSR = BaseObjs._editor.SelectCrossingWindow(pnt3dLL, pnt3dUR, filter); if (PSR.Status == PromptStatus.OK) { ids = PSR.Value.GetObjectIds(); } else { return; } try { using (Transaction tr = BaseObjs.startTransactionDb()) { foreach (ObjectId idObj in ids) { Entity ENT = (Entity)idObj.GetObject(OpenMode.ForWrite, true); ENT.Erase(); } tr.Commit(); } // end using } catch (System.Exception ex) { BaseObjs.writeDebug(ex.Message + " Misc.cs: line: 433"); } }
getXRefEntsByLayer(ObjectId idBlkRef, string nameLayer) { ObjectIdCollection idEnts = new ObjectIdCollection(); try { using (Transaction tr = BaseObjs.startTransactionDb()) { BlockReference br = (BlockReference)tr.GetObject(idBlkRef, OpenMode.ForRead); ObjectId idbtr = br.BlockTableRecord; BlockTableRecord btr = (BlockTableRecord)idbtr.GetObject(OpenMode.ForRead); foreach (ObjectId idObj in btr) { Entity ent = (Entity)tr.GetObject(idObj, OpenMode.ForRead); if (ent.Layer.Contains(nameLayer)) { idEnts.Add(idObj); } } tr.Commit(); } } catch (System.Exception ex) { BaseObjs.writeDebug(ex.Message + " xRef.cs: line: 1049"); } return(idEnts); }
deleteObjs(TypedValue[] TVs) { SelectionSet ss = Select.buildSSetBase(TVs, true); if (ss == null) { return; } try { using (Transaction tr = BaseObjs.startTransactionDb()) { foreach (ObjectId idObj in ss.GetObjectIds()) { Entity ENT = (Entity)idObj.GetObject(OpenMode.ForWrite, true); ENT.Erase(); } tr.Commit(); } // end using } catch (System.Exception ex) { BaseObjs.writeDebug(ex.Message + " Misc.cs: line: 458"); } }
getLinetypeTableRecord(string name) { LinetypeTableRecord LTtr = null; try { using (Transaction tr = BaseObjs.startTransactionDb()) { LinetypeTable LTT = getLineTypeTable(); if (LTT.Has(name) == true) { LTtr = (LinetypeTableRecord)tr.GetObject(LTT[name], OpenMode.ForRead); } else { BaseObjs._db.LoadLineTypeFile(name, "ACAD.LIN"); LTtr = (LinetypeTableRecord)tr.GetObject(LTT[name], OpenMode.ForRead); } tr.Commit(); } } catch (System.Exception ex) { BaseObjs.writeDebug(ex.Message + " LineType.cs: line: 63"); } return(LTtr); }
addPoly(Point3dCollection pnt3ds, string nameLayer = "0", short color = 256) { ObjectId idPoly = ObjectId.Null; Point2d pnt2d; Polyline poly = new Polyline(); Layer.manageLayers(nameLayer); try { using (Transaction tr = BaseObjs.startTransactionDb()) { BlockTableRecord MS = Blocks.getBlockTableRecordMS(); int i = -1; poly.SetDatabaseDefaults(); foreach (Point3d pnt3d in pnt3ds) { i = ++i; pnt2d = new Point2d(pnt3d.X, pnt3d.Y); poly.AddVertexAt(i, pnt2d, 0, 0, 0); } poly.Layer = nameLayer; poly.Color = Color.FromColorIndex(ColorMethod.ByBlock, color); idPoly = MS.AppendEntity(poly); tr.AddNewlyCreatedDBObject(poly, true); tr.Commit(); }// end using } catch (System.Exception ex) { BaseObjs.writeDebug(ex.Message + " Draw.cs: line: 332"); } return(idPoly); }