C3D-0038 · READ-ONLY: isolate the stranded sewer easement label [SSE-LABEL-FAR] error
Measures every Civil label on the sewer/prop/easement layers against its parent feature and reports only those more than 60 ft away, with parent handle/type, distance, style and dragged state. Isolates the label that points way out from the drawing. No changes.
C# payload
// READ-ONLY. Which sewer-easement label is stranded far from the thing it labels?
//
// The previous dump was too long to read. This one measures each Civil label's distance from its
// PARENT feature and prints ONLY the outliers (> 60 ft), so the one "pointing way out here" is
// isolated. Also reports whether the label carries a dragged-state offset, because a label whose
// anchor is its parent will snap back when you try to drag it. No changes.
var ms = (BlockTableRecord)Tx.GetObject(SymbolUtilityServices.GetBlockModelSpaceId(Db), OpenMode.ForRead);
int n = 0, far = 0;
foreach (ObjectId id in ms) {
var lbl = Tx.GetObject(id, OpenMode.ForRead) as Autodesk.Civil.DatabaseServices.Label;
if (lbl == null) continue;
var ent = (Autodesk.AutoCAD.DatabaseServices.Entity)lbl;
string lay = ent.Layer;
if (!(lay.StartsWith("SS-") || lay.StartsWith("C-PROP") || lay.Contains("SEWER") || lay.Contains("EASEMENT"))) continue;
n++;
Point3d loc;
try { loc = lbl.LabelLocation; } catch { continue; }
// where is the parent?
Point3d anchor = loc; string ptype = "?"; string phandle = "?";
double d = -1.0;
try {
var par = Tx.GetObject(lbl.FeatureId, OpenMode.ForRead);
ptype = par.GetType().Name;
phandle = par.Handle.ToString();
var pent = par as Autodesk.AutoCAD.DatabaseServices.Entity;
if (pent != null) {
var e = pent.GeometricExtents;
anchor = new Point3d((e.MinPoint.X + e.MaxPoint.X) / 2.0,
(e.MinPoint.Y + e.MaxPoint.Y) / 2.0, 0.0);
d = Math.Sqrt(Math.Pow(loc.X - anchor.X, 2) + Math.Pow(loc.Y - anchor.Y, 2));
}
} catch { }
if (d < 60.0) continue; // sitting on its parent - not the problem
far++;
Log("");
Log(String.Format("STRANDED [{0}] {1} layer={2}", ent.ObjectId.Handle, lbl.GetType().Name, lay));
Log(String.Format(" label at {0:F2},{1:F2}", loc.X, loc.Y));
Log(String.Format(" parent [{0}] {1} centre {2:F2},{3:F2} DISTANCE {4:F1} ft", phandle, ptype, anchor.X, anchor.Y, d));
try { Log(" style " + lbl.StyleName); } catch { }
try { Log(" dragged " + lbl.IsLabelDragged); } catch (System.Exception ex) { Log(" dragged? " + ex.Message); }
try { Log(" visible " + ent.Visible); } catch { }
}
Log("");
Log("civil labels on sewer/prop/easement layers: " + n + " stranded (>60ft from parent): " + far);
Result
Notes
What worked, what didn't, job-specific gotchas — flagged notes feed the recipes.
No notes yet.