C3D-MHRENAME · Rename SSMH labels to as-built A-numbers done
Renames SEWER_MANHOLE_TEXT to the as-built A-numbers, keeping the surveyed point number in parentheses. 1106=A16, 1105=A14 (user controls), 1103=A12, 1094=A10 (user correction), 1099=A9, 100=A8. Leaves 1111/1095/101/102 alone - not part of the as-built.
C# payload
// Rename SEWER_MANHOLE_TEXT labels from surveyed point numbers to the as-built A-numbers.
// Mapping solved by walking the sewer run sequence (not proximity — the built locations drift
// from the as-built, so nearest-neighbour mis-assigns). Anchors 1106=A16 and 1105=A14 are the
// user's controls. Keeps the original point number in parentheses so nothing is lost.
// Idempotent: skips labels already renamed.
var bt = (BlockTable)Tx.GetObject(Db.BlockTableId, OpenMode.ForRead);
var ms = (BlockTableRecord)Tx.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForRead);
var map = new Dictionary<string,string> {
{ "SSMH 1106", "SSMH A16 (1106)" }, // control - exact
{ "SSMH 1105", "SSMH A14 (1105)" }, // control - exact
{ "SSMH 1103", "SSMH A12 (1103)" }, // 2.6 ft along-run
{ "SSMH 1094", "SSMH A10 (1094)" }, // per user: 1094 is A10, not 1111
{ "SSMH 1099", "SSMH A9 (1099)" }, // 3.7 ft
{ "SSMH 100", "SSMH A8 (100)" }, // 19.0 ft
// NOT renamed - per user these are not part of the as-built:
// SSMH 1111, SSMH 1095, SSMH 101, SSMH 102
};
int done = 0, skip = 0;
foreach (ObjectId id in ms) {
var o = Tx.GetObject(id, OpenMode.ForRead);
if (!(o is DBText t) || t.Layer != "SEWER_MANHOLE_TEXT") continue;
var s = (t.TextString ?? "").Trim();
if (s.Contains("(") && s.Contains("SSMH A")) { skip++; continue; } // already renamed
if (!map.ContainsKey(s)) continue;
var w = (DBText)Tx.GetObject(id, OpenMode.ForWrite);
string old = w.TextString;
w.TextString = map[s];
var chk = (DBText)Tx.GetObject(id, OpenMode.ForRead);
if (chk.TextString != map[s]) { Log($" FAILED '{old}'"); continue; }
Log($" \"{old}\" -> \"{chk.TextString}\" (verified)");
done++;
}
Log($"RENAMED: {done}, already-renamed: {skip}");
Log("Left alone (not part of the as-built, per user): SSMH 1111, 1095, 101, 102.");
Result
Log
"SSMH 1106" -> "SSMH A16 (1106)" (verified) "SSMH 1105" -> "SSMH A14 (1105)" (verified) "SSMH 1103" -> "SSMH A12 (1103)" (verified) "SSMH 1094" -> "SSMH A10 (1094)" (verified) "SSMH 1099" -> "SSMH A9 (1099)" (verified) "SSMH 100" -> "SSMH A8 (100)" (verified) RENAMED: 6, already-renamed: 0 Left alone (not part of the as-built, per user): SSMH 1111, 1095, 101, 102.
Notes
What worked, what didn't, job-specific gotchas — flagged notes feed the recipes.
No notes yet.