C3D-0330 · Read the actual text of every segment label (explode to MText) + list open drawings [C3D-PSL4] error
Read-only. Explodes each ParcelSegmentLabel in memory to read the text it displays, so the 408.70 / 79.34 / 1089.00 / 150.35 labels can be matched by handle. Also lists every open drawing in the session.
C# payload
Log("drawing: " + Db.Filename);
Log("open drawings:");
foreach (Autodesk.AutoCAD.ApplicationServices.Document d in
Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager)
Log(" " + d.Name);
Log("");
var ms = (BlockTableRecord)Tx.GetObject(SymbolUtilityServices.GetBlockModelSpaceId(Db), OpenMode.ForRead);
// Explode each label to read what it actually says on screen.
int n = 0;
foreach (ObjectId id in ms) {
var obj = Tx.GetObject(id, OpenMode.ForRead);
string cls = obj.GetType().Name;
if (cls != "ParcelSegmentLabel" && cls != "GeneralSegmentLabel") continue;
var ent = (Autodesk.AutoCAD.DatabaseServices.Entity)obj;
n++;
var parts = new DBObjectCollection();
string txt = "";
try {
ent.Explode(parts);
foreach (DBObject p in parts) {
var m = p as MText; var d = p as DBText;
if (m != null) txt += " | " + m.Contents;
else if (d != null) txt += " | " + d.TextString;
}
} catch (System.Exception e) { txt = "<explode: " + e.Message + ">"; }
if (txt.StartsWith(" | ")) txt = txt.Substring(3);
txt = txt.Replace("\n"," ").Replace("\r","");
if (txt.Length > 160) txt = txt.Substring(0,160) + "...";
Log(string.Format("[{0}] {1,-20} layer={2,-18} \"{3}\"", ent.Handle, cls, ent.Layer, txt));
}
Log("");
Log("segment labels: " + n);
Result
Notes
What worked, what didn't, job-specific gotchas — flagged notes feed the recipes.
No notes yet.