C3D-0097 · Append - 8" PVC to the sewer length labels [PVC-SUFFIX] done
Appends the pipe size to each SEWER_LINE_TEXT length label in the format the user applied to A16 to A14 (132.52 - 8 inch PVC). Slope labels are skipped, the 55.14 six inch stub is excluded by handle, and labels already carrying a PVC suffix are left alone so a re-run is a no-op.
C# payload
// Append the pipe size to each sewer length label, matching the format the user applied to
// A16->A14: 132.52' - 8" PVC
//
// Targets: every MText on SEWER_LINE_TEXT whose text ends in an apostrophe (a length label) and
// does not already carry a "PVC" suffix. Slope labels (containing %) are skipped.
//
// 2EF51 (55.14') is the 6" PVC stub, not 8" - it is EXCLUDED by handle.
// Idempotent: a label already ending in PVC is left alone, so a re-run appends nothing.
var ms = (BlockTableRecord)Tx.GetObject(SymbolUtilityServices.GetBlockModelSpaceId(Db), OpenMode.ForRead);
const string SUFFIX = "\" PVC"; // preceded by the size below
const string SIZE = " - 8";
const string SKIP = "2EF51"; // the 6-inch stub
int done = 0, already = 0, skipped = 0;
foreach (ObjectId id in ms) {
var probe = Tx.GetObject(id, OpenMode.ForRead) as MText;
if (probe == null || probe.Layer != "SEWER_LINE_TEXT") continue;
string cur = probe.Contents.Trim();
if (cur.IndexOf('%') >= 0) continue; // slope label
if (!cur.EndsWith("'")) { } // fallthrough below
if (cur.IndexOf("PVC") >= 0) { already++; continue; } // already suffixed
if (!cur.EndsWith("'")) continue; // not a plain length label
if (probe.Handle.ToString() == SKIP) { skipped++; Log(" [" + SKIP + "] " + cur + " SKIPPED (6\" stub)"); continue; }
var w = (MText)Tx.GetObject(id, OpenMode.ForWrite);
w.Contents = cur + SIZE + SUFFIX;
done++;
Log(" [" + probe.Handle + "] " + cur + " -> " + w.Contents);
}
Log("");
Log("appended: " + done + " already had PVC: " + already + " skipped: " + skipped);
int withPvc = 0, lengths = 0;
foreach (ObjectId id in ms) {
var mt = Tx.GetObject(id, OpenMode.ForRead) as MText;
if (mt == null || mt.Layer != "SEWER_LINE_TEXT") continue;
string c = mt.Contents.Trim();
if (c.IndexOf('%') >= 0) continue;
lengths++;
if (c.IndexOf("PVC") >= 0) withPvc++;
}
Log("length labels: " + lengths + ", carrying a PVC suffix: " + withPvc + " (verified)");
Ed.Regen();
Result
Log
[2EF4E] 12.07' -> 12.07' - 8" PVC [2EF50] 133.21' -> 133.21' - 8" PVC [2EF51] 55.14' SKIPPED (6" stub) [2EF52] 86.31' -> 86.31' - 8" PVC [2EF53] 30.97' -> 30.97' - 8" PVC [2EF54] 133.46' -> 133.46' - 8" PVC [2EF55] 80.46' -> 80.46' - 8" PVC [2EF56] 161.58' -> 161.58' - 8" PVC [2EF57] 359.02' -> 359.02' - 8" PVC [2EF58] 80.02' -> 80.02' - 8" PVC [2EF59] 155.37' -> 155.37' - 8" PVC [2EF5A] 19.54' -> 19.54' - 8" PVC [2EF5B] 8.66' -> 8.66' - 8" PVC appended: 12 already had PVC: 1 skipped: 1 length labels: 14, carrying a PVC suffix: 13 (verified)
Notes
What worked, what didn't, job-specific gotchas — flagged notes feed the recipes.
No notes yet.