Does anyone know a way to access/loop over the CadMep+ properties in Autocad?
I have no issues accessing the ‘General’ properties of entities but the CadMep ones cannot seem to be read.
People have mentioned the AddModifyPart sample which is supposed to come with AutoCAD MEP but this doesn’t exist on my installation. I’m using AutoCAD MEP 2014.
Here's the code I use to get the 'General' properties:
static private void GetEverything(ObjectId msId) {
Document doc = Application.DocumentManager.MdiActiveDocument;
Database db = doc.Database;
Editor ed = doc.Editor;
using (Transaction tr = doc.TransactionManager.StartTransaction()) {
BlockTable blockTable = tr.GetObject(db.BlockTableId, OpenMode.ForRead) as BlockTable;
BlockTableRecord btrMs = (BlockTableRecord)tr.GetObject(msId, OpenMode.ForWrite);
// Test each entity in the container...
foreach (ObjectId entId in btrMs) {
Entity ent = tr.GetObject(entId, OpenMode.ForRead) as Entity;
Type tType = ent.GetType();
if (ent != null) {
ObjectId entityId = ent.Id;
String entLayer = ent.Layer;
String entType = tType.Name;
String objName = entityId.ObjectClass.Name;
//String entBlockName = ent.BlockName; // all are *Model_Space
//ObjectId entBlockId = ent.BlockId; // all are (8796087795216)
//Object entAcadObj = ent.AcadObject; // all are System.__ComObject
//Type entAcadType = entAcadObj.GetType(); // all are System.__ComObject
// Write the string to a file.
System.IO.StreamWriter file = new System.IO.StreamWriter("D:\\Autodesk\\ms_rnd\\output.txt", true);
file.WriteLine(entityId + ": " + entType + ": " + entLayer + ": " + objName);
file.Close();
}
}
}
}
All the CadDuct objects have a type of 'ImpEntity' and ObjectClass Name of 'MapsContainer'