- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Good morning everyone,
I've got a question in regards to performing some specific explode commands. You see, I'm putting together a routine that will take all the "Equipment" objects from one of our drawings, put them in indivudal DWG files and explode them. I'm doing this so they can be imported into Revit. This is all currently being done in the AutoCAD Core Console.
I've got the first two steps down. Using the Core Console I can grab all of the Equipment objects I mentioned and then import them into their own individual DWG files, but I can't quite get the 'explode' to work. As of now, it just does nothing. I need to explode these objects so they remove all their properties, but retain their 3D Geometry.
Below is the code, it's wrapped in a foreach statement (not included), I'm currently using to try and get this to work, anyone have any suggestions/thoughts as to why it's not working?
using (Transaction tr = db.TransactionManager.StartTransaction()) { // Open new Database using (Database newDb = new Database(true, true)) { // Make collection for single object. ObjectIdCollection coll = new ObjectIdCollection(); coll.Add(thisEquipItem.ObjId); using (Transaction newTr = newDb.TransactionManager.StartTransaction()) { // Get BlockTable/BlockTableRecord to insert model into newDb. // For these to import correctly, they need to be imported into Model Space. BlockTable bt = newTr.GetObject(newDb.BlockTableId, OpenMode.ForRead) as BlockTable; BlockTableRecord btr = newTr.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForRead) as BlockTableRecord; IdMapping idMap = new IdMapping(); newDb.WblockCloneObjects(coll, btr.ObjectId, idMap, DuplicateRecordCloning.Ignore, false); newTr.Commit(); } // Explode the object. using (Transaction exTr = newDb.TransactionManager.StartTransaction()) { BlockTable exBt = exTr.GetObject(newDb.BlockTableId, OpenMode.ForRead) as BlockTable; BlockTableRecord exBtr = exTr.GetObject(exBt[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord; foreach (ObjectId obj in exBtr) { Entity ent = exTr.GetObject(obj, OpenMode.ForWrite) as Entity; DBObjectCollection entitySet = new DBObjectCollection(); ent.Explode(entitySet); } exTr.Commit(); } dwgName = exportPath + @"\" + number + ".dwg"; newDb.SaveAs(dwgName, DwgVersion.Current); } tr.Commit(); }
Solved! Go to Solution.