updatePoly3dCoordinates(this ObjectId idPoly3dOrg, List <Point3d> pnts3d) { ObjectId idPoly3dNew = ObjectId.Null; Polyline3d poly3dNew = new Polyline3d(); using (Transaction tr = BaseObjs.startTransactionDb()) { BlockTableRecord ms = Blocks.getBlockTableRecordMS(); idPoly3dNew = ms.AppendEntity(poly3dNew); poly3dNew.SetDatabaseDefaults(); poly3dNew.Layer = idPoly3dOrg.getLayer(); foreach (Point3d pnt3dX in pnts3d) { PolylineVertex3d v3d = new PolylineVertex3d(pnt3dX); poly3dNew.AppendVertex(v3d); tr.AddNewlyCreatedDBObject(v3d, true); } tr.AddNewlyCreatedDBObject(poly3dNew, true); tr.Commit(); } using (Transaction tr1 = BaseObjs.startTransactionDb()) { DBObject dbObjOrg = tr1.GetObject(idPoly3dOrg, OpenMode.ForRead); DBObject dbObjNew = tr1.GetObject(idPoly3dNew, OpenMode.ForRead); dbObjNew.UpgradeOpen(); dbObjNew.SwapIdWith(dbObjOrg.ObjectId, true, true); idPoly3dNew.delete(); tr1.Commit(); } }
addVertexToPoly3d(this ObjectId idPoly3dOrg, Point3d pnt3d, int pos, Handle hCgPNt) { List <Point3d> pnts3d = idPoly3dOrg.getCoordinates3dList(); ObjectId idPoly3dNew = ObjectId.Null; Polyline3d poly3dNew = new Polyline3d(); using (Transaction tr = BaseObjs.startTransactionDb()) { BlockTableRecord ms = Blocks.getBlockTableRecordMS(); idPoly3dNew = ms.AppendEntity(poly3dNew); poly3dNew.SetDatabaseDefaults(); poly3dNew.Layer = idPoly3dOrg.getLayer(); pnts3d.Insert(pos + 1, pnt3d); foreach (Point3d pnt3dX in pnts3d) { PolylineVertex3d v3d = new PolylineVertex3d(pnt3dX); poly3dNew.AppendVertex(v3d); tr.AddNewlyCreatedDBObject(v3d, true); } tr.AddNewlyCreatedDBObject(poly3dNew, true); tr.Commit(); } using (Transaction tr1 = BaseObjs.startTransactionDb()) { DBObject dbObjOrg = tr1.GetObject(idPoly3dOrg, OpenMode.ForRead); DBObject dbObjNew = tr1.GetObject(idPoly3dNew, OpenMode.ForRead); dbObjNew.UpgradeOpen(); dbObjNew.SwapIdWith(dbObjOrg.ObjectId, true, true); idPoly3dNew.delete(); tr1.Commit(); } ResultBuffer rb = idPoly3dOrg.getXData(apps.lnkBrks); TypedValue[] tvs = rb.AsArray(); TypedValue[] tvsNew = new TypedValue[tvs.Length + 1]; for (int i = 0; i < pos + 2; i++) { tvsNew[i] = tvs[i]; } tvsNew.SetValue(new TypedValue(1005, hCgPNt), pos + 2); for (int i = pos + 2; i < tvs.Length; i++) { tvsNew[i + 1] = tvs[i]; } idPoly3dOrg.clearXData(apps.lnkBrks); idPoly3dOrg.setXData(tvsNew, apps.lnkBrks); }