Hello
We use Real DWG 2014 in standalone application. I can't explode AecDbScheduleTable objects, collection passed to Explode() method is always empty.
Sample code below:
public static void ExplodeScheduleTable(string strFileName) { try { Database db = new Database(false, true); db.ReadDwgFile(strFileName, FileShare.None, false, null); using (db.TransactionManager.StartTransaction()) { BlockTable blockTable = db.BlockTableId.GetObject(OpenMode.ForRead) as BlockTable; if (blockTable != null) { foreach (ObjectId blockId in blockTable) { BlockTableRecord block = blockId.GetObject(OpenMode.ForRead) as BlockTableRecord; if (!block.IsLayout) continue; foreach (ObjectId objectId in block) { try { Entity dbObject = (Entity)objectId.GetObject(OpenMode.ForWrite, false, true); if (dbObject.GetRXClass().Name.StartsWith("AecDb")) { Console.WriteLine(dbObject.GetRXClass().Name); DBObjectCollection objects = new DBObjectCollection(); dbObject.Explode(objects); Console.WriteLine("Exploded:" + objects.Count); } } catch (Exception exc) { Console.WriteLine(exc.Message); } } } } } db.Dispose(); } catch (Exception exc) { Console.WriteLine(exc.Message); } }
After executing this method I can see such result:
AecDbSlab Exploded:1 AecDbSlab Exploded:1 AecDbSlab Exploded:1 AecDbSlab Exploded:1 AecDbSlab Exploded:1 AecDbMvBlockRef Exploded:1 AecDbScheduleTable Exploded:0
Solved! Go to Solution.
Solved by StephenPreston. Go to Solution.
An entity is not required to allow itself to be exploded. It can return a null array of objects from its explode method, or it can return eNotImplemented. If the creator of that entity has chosen not to allow it to be explodable, then there's nothing you can do after the fact.
But there is a (slightly more complicated) alternative. Depending on what you need, you may have success querying (and recreating) the raw geometry from such entity's using a technique similar to that explained here for Plant 3D objects - http://adndevblog.typepad.com/autocad/2013/07/extracting-the-raw-geometry-from-plant3d-objects.html. An older version of the ObjectARX SDK had a C++ and .NET samples for this. They were called acgisamp or gisamp or something similar.
I'm trying to use worldDraw() method but it doesn't work for AEC objects. No geometry has been obtained. I tested this using dumpdwg sample in RealDWG 2014.
AEC objects are usually view dependent, so you'll have to also call viewportDraw.
Ok, I have implemented ViewportDraw and ViewportGeometry classes. How can I get Autodesk.AutoCAD.GraphicsInterface.Viewport object?
>>How can I get Autodesk.AutoCAD.GraphicsInterface.Viewport object?
You have to derive your own so you can trap the appropriate calls.
I was a bit vague with the sample names in my first reply, so I went back to an old ObjectARX SDK (ObjectARX 2009) to check the exact names. The ObjectARX sample is 'acgisamp' in the graphics subfolder, and the .NET sample is 'GiMeta' in the DotNet subfolder. If you don't have access to ObjectARX SDKs that old, then please send me a message with your private email address and I'll send them to you. The samples are proofs of concept though - not everything you need is necessatily implemented in the samples.
The idea is that you implement your own versions of all the Autodesk.AutoCAD.GraphicsInterface classes you need, then you call the entity's WorldDraw function passing in your custom GraphicsInterface.WorldDraw object.
If the WorldDraw fucntion returns Fase, then you call the entity's ViewportDraw function passing in an instance of your custom GraphicsInterface.ViewportDraw class.