I am attempting to interrogate AutoCAD objects from C#. I am interested in being able to grab all of the properties of a given object and output them. For example, in the below snippit of code I am looping through all of the items on screen and just reflecting against their first-class properties. The objects I care about often have a first-class AcadObject property which seems to hold the data I am after. The problem is that this is a __ComObject and that many of its nested propetry objects do no provide properties via reflection. For example, obj.AcadObject.Connectors appears to be a collection of connector objects, which I am very interested in. I can reflect to that depth using the debugger, but from there on in I am left guessing at properties of the Connectors collection and its objects (the .Net debugger does show a Count property which tipped me off). Using C#'s dynamic keyword and the DLR/COM binders built into .Net 4 I can probe these objects. For example, I can use a dynamic expression to grab obj.AcadObject.Connectors[0].Name, guessing that it had a name attribute. I am willing to use dynamic expressions to grab these properties but I need to know what the properties are in the first place. I have researched quite a bit and seem to be missing a reference to what these objects look like. There are a few other objects hanging off of AcadObject as well that I would like to export.

I am actualying getting all of the elements I want by getting the BlockTableRecord for the ModelSpace. My issue is enumerating all of the properties in the objects I retrieve like Width, Height, Diameter, etc. Since I am getting various types of drawing objects (Pipe, Duct, DuctFitting, Mesh, Line, etc) I don't know what the properties are beforehand and so I want a dynamic way of looking them up.
–
Jason JacksonOct 24 '12 at 15:37

You may find the MgdDbg utility to be of particular use when exploring a given drawing's Database... Depending on what you're after, and your version of AutoCAD, as Events, etc. are hard-coded rather than dynamic as Tony states here.

This isn't a perfect answer but I am going to put it here so it might help someone else. Using the immediate window I cast the obj.Acad to a dynamic, and then referenced down to the object in question such Connectors[0]. At that point I recast that to an object and was able to inspect it with a watch. Example code as it would run in the immediate window with a debug break after the obj set:

The best I can figure is the the COM binder for the DLR is marshaling stuff over for me, and then once I get it cast back .Net debugger can figure out the properties. I am working on getting this discovery working with reflection...