public ElevationAdjuster(Entity ent) : base(ent) { mMsgFilter = new EM_MouseWheelMsgFilter(); System.Windows.Forms.Application.AddMessageFilter(mMsgFilter); mElevOffset = (ent as CogoPoint).Elevation; }
private void ExplodeIntoACAD2000Objects(string drawingName) { bool eraseOrig = true; try { if (drawingName == null) { throw new ArgumentNullException(nameof(drawingName)); } using (Autodesk.AutoCAD.DatabaseServices.Database db = new Autodesk.AutoCAD.DatabaseServices.Database(false, false)) { db.ReadDwgFile(drawingName, FileOpenMode.OpenForReadAndWriteNoShare, true, null); using (Transaction tr = db.TransactionManager.StartTransaction()) { // Collect our exploded objects in a single collection var selected = PGA.AcadUtilities.AcadUtilities. GetAllObjectIdsInModel(db, false); DBObjectCollection objs = new DBObjectCollection(); // Loop through the selected objects foreach (ObjectId so in selected) { // Open one at a time Entity ent = (Entity)tr.GetObject( so, OpenMode.ForRead ); // Explode the object into our collection ent.Explode(objs); // Erase the original, if requested if (ent.GetType() == typeof(C3DLandDb.FeatureLine)) { if (eraseOrig) { ent.UpgradeOpen(); ent.Erase(); } } } // Now open the current space in order to // add our resultant objects BlockTableRecord btr = (BlockTableRecord)tr.GetObject( db.CurrentSpaceId, OpenMode.ForWrite ); // Add each one of them to the current space // and to the transaction foreach (DBObject obj in objs) { Entity ent = (Entity)obj; btr.AppendEntity(ent); tr.AddNewlyCreatedDBObject(ent, true); } // And then we commit tr.Commit(); } var path = Path.GetDirectoryName(drawingName); var file = Path.GetFileName(drawingName); var output = Path.Combine(path, "ACAD-" + file); db.SaveAs(output, DwgVersion.Current); } } catch (Exception ex) { MessengerManager.MessengerManager.LogException(ex); } }