C3D-0056 · READ-ONLY: re-count and list everything on SEWER_MANHOLE_TEXT [MHTXT-COUNT] error
Earlier audit reported 21 MText + 5 Leader on SEWER_MANHOLE_TEXT and the user does not see that many. Lists every entity on the layer with its text, position and height, plus the layer on/off/frozen state. No changes.
C# payload
// READ-ONLY. Re-count SEWER_MANHOLE_TEXT. Earlier audit said 21 MText + 5 Leader; user does not
// see that many. Print EVERY entity on the layer with its text and position so any duplicate,
// stacked or off-site one is visible. Also report the layer's on/off/frozen state, since a frozen
// or off layer would explain a count that cannot be seen. Nothing is modified.
var ms = (BlockTableRecord)Tx.GetObject(SymbolUtilityServices.GetBlockModelSpaceId(Db), OpenMode.ForRead);
var lt = (LayerTable)Tx.GetObject(Db.LayerTableId, OpenMode.ForRead);
const string LAY = "SEWER_MANHOLE_TEXT";
if (lt.Has(LAY)) {
var l = (LayerTableRecord)Tx.GetObject(lt[LAY], OpenMode.ForRead);
Log("layer " + LAY + ": off=" + l.IsOff + " frozen=" + l.IsFrozen + " locked=" + l.IsLocked);
}
var rows = new List<string>();
int nm = 0, nl = 0, no = 0;
foreach (ObjectId id in ms) {
Autodesk.AutoCAD.DatabaseServices.DBObject o;
try { o = Tx.GetObject(id, OpenMode.ForRead); } catch { continue; }
var ent = o as Autodesk.AutoCAD.DatabaseServices.Entity;
if (ent == null || ent.Layer != LAY) continue;
var mt = o as MText;
var ld = o as Leader;
if (mt != null) {
nm++;
string t = mt.Contents.Replace("\P", " | ");
rows.Add(String.Format(" MText [{0}] at {1:F2},{2:F2} h={3:F2} \"{4}\"",
o.Handle, mt.Location.X, mt.Location.Y, mt.TextHeight, t));
} else if (ld != null) {
nl++;
rows.Add(String.Format(" Leader [{0}] verts={1} start {2:F2},{3:F2}",
o.Handle, ld.NumVertices,
ld.VertexAt(0).X, ld.VertexAt(0).Y));
} else {
no++;
rows.Add(" " + o.GetType().Name + " [" + o.Handle + "]");
}
}
rows.Sort();
foreach (var r in rows) Log(r);
Log("");
Log("SEWER_MANHOLE_TEXT: MText=" + nm + " Leader=" + nl + " other=" + no + " TOTAL=" + (nm + nl + no));
Result
Notes
What worked, what didn't, job-specific gotchas — flagged notes feed the recipes.
No notes yet.