Message 1 of 5
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Dear All,
I got an error when I explode the region.
Please help me correct below code.
Thanks,
Naing Oo
public static void ExplodeRegion(Database db, Editor edt)
{
using (Transaction acTrans = db.TransactionManager.StartTransaction())
{
BlockTable acBlkTbl;
acBlkTbl = acTrans.GetObject(db.BlockTableId, OpenMode.ForRead) as BlockTable;
BlockTableRecord acBlkTblRec;
acBlkTblRec = acTrans.GetObject(acBlkTbl[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord;
SelectionSet acSSet = edt.SelectAll().Value;
if (acSSet == null)
return;
ObjectId[] oids = acSSet.GetObjectIds();
foreach (ObjectId id in oids)
{
Region reg = (DBObject)acTrans.GetObject(id, OpenMode.ForWrite) as Region;
if (reg != null)
{
DBObjectCollection acDBObjColl = new DBObjectCollection();
reg.Explode(acDBObjColl);
acBlkTblRec.UpgradeOpen();
foreach (DBObject dbObj in acDBObjColl)
{
Entity acEnt = dbObj as Entity;
acBlkTblRec.AppendEntity(acEnt);
acTrans.AddNewlyCreatedDBObject(dbObj, true);
}
}
}
acTrans.Commit();
}
}
Solved! Go to Solution.