Entity.Explode() method does not output circles to DBObject

Entity.Explode() method does not output circles to DBObject

Anonymous
Not applicable
651 Views
1 Reply
Message 1 of 2

Entity.Explode() method does not output circles to DBObject

Anonymous
Not applicable

Hi all - I'm creating a command which creates a new document, copies a block to it, and then explodes that block into machine-readable geometric entities that can be saved as a .dxf and sent to the machine in our shop. Right now the code is mostly functional, however when the "explode" method is called the resulting entities do not include any circles that were part of the original block. At first I thought this was an issue resulting from block anonymity, as many of these circles were copied from standard-sized bore circles, however even non-anonymized circles I added to the block as a test also get dropped. I've included part of my code below: 

Transaction trans = db.TransactionManager.StartTransaction();
                    try
                    {
                        BlockReference bR = trans.GetObject(id, OpenMode.ForRead) as BlockReference;
                        BlockTableRecord bTR = trans.GetObject(bR.BlockTableRecord, OpenMode.ForRead) as BlockTableRecord;
                        if (bTR.Comments.Contains("_MR_"))
                        {
                            ObjectIdCollection idCollection = new ObjectIdCollection();
                            idCollection.Add(id);
                            Document newDoc = Application.DocumentManager.Add("acad.dwt");
                            Database destDB = newDoc.Database;
                            Application.DocumentManager.MdiActiveDocument = newDoc;
                            using (DocumentLock docLock = newDoc.LockDocument())
                            {
                                using (Transaction trans0 = destDB.TransactionManager.StartTransaction())
                                {
                                    trans0.TransactionManager.QueueForGraphicsFlush();
                                    IdMapping iMap = new IdMapping();
                                    db.WblockCloneObjects(idCollection, destDB.CurrentSpaceId, iMap, DuplicateRecordCloning.Ignore, false);
                                    PromptSelectionResult pSR = newDoc.Editor.SelectAll();
                                    foreach(ObjectId id0 in pSR.Value.GetObjectIds())
                                    {
                                        BlockTable destBT = trans0.GetObject(destDB.BlockTableId, OpenMode.ForRead) as BlockTable;
                                        BlockTableRecord destBTR = trans0.GetObject(destBT[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord;
                                        DBObjectCollection dBObjectCollection = new DBObjectCollection();
                                        Entity entity = trans0.GetObject(id0, OpenMode.ForWrite) as Entity;
                                        entity.Explode(dBObjectCollection);
                                        entity.Erase();
                                        foreach(Entity ent in dBObjectCollection)
                                        {
                                            destBTR.AppendEntity(ent);
                                            trans0.AddNewlyCreatedDBObject(ent, true);
                                        }
                                    }
                                    Application.DocumentManager.MdiActiveDocument = doc;
                                    trans0.Commit();
                                    destDB.DxfOut(rootPath + @"\" + pDirectory.StringResult + "_" + i.ToString() + ".dxf", 16, DwgVersion.AC1009);
0 Likes
652 Views
1 Reply
Reply (1)
Message 2 of 2

Anonymous
Not applicable

I've attached pictures of the inputted block and resulting drawing below.

input_circles.pngresult_circles.png

0 Likes