C3D-0328 · Dump ParcelSegmentLabel properties - find how the distance text is exposed [C3D-PSL2] rejected
Read-only. Reflects every property on the first segment label so we can see where 408.70 / 79.34 / 1089.00 / 150.35 live, then lists all 21 with handle, layer, style and labelled feature.
C# payload
// The 21 ParcelSegmentLabels gave no text via Text/LabelText. Dump every readable string
// property on each one so we can see how the distance is exposed, plus geometry so the four
// can be matched by the underlying segment length if the text is not reachable.
Log("drawing: " + Db.Filename);
var ms = (BlockTableRecord)Tx.GetObject(SymbolUtilityServices.GetBlockModelSpaceId(Db), OpenMode.ForRead);
bool dumpedProps = false;
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++;
if (!dumpedProps) {
dumpedProps = true;
Log("--- properties on " + obj.GetType().FullName + " ---");
foreach (var pi in obj.GetType().GetProperties()) {
if (pi.GetIndexParameters().Length > 0) continue;
string val;
try { var v = pi.GetValue(obj, null); val = v == null ? "null" : v.ToString(); }
catch (System.Exception e) { val = "<" + e.GetType().Name + ">"; }
if (val.Length > 90) val = val.Substring(0,90) + "...";
Log(string.Format(" {0,-28} {1,-22} = {2}", pi.Name, pi.PropertyType.Name, val));
}
Log("");
}
// geometry of the labelled segment, so we can match 408.70 etc by length
double len = -1;
string featName = "";
try {
var fp = obj.GetType().GetProperty("FeatureId");
if (fp != null) {
var fid = (ObjectId)fp.GetValue(obj, null);
if (!fid.IsNull) {
var f = Tx.GetObject(fid, OpenMode.ForRead);
featName = f.GetType().Name;
var np = f.GetType().GetProperty("Name");
if (np != null) featName += " \"" + np.GetValue(f, null) + "\"";
}
}
} catch { }
string styleName = "";
try {
var sp = obj.GetType().GetProperty("StyleId");
var sid = (ObjectId)sp.GetValue(obj, null);
if (!sid.IsNull) {
var st = Tx.GetObject(sid, OpenMode.ForRead);
styleName = (st.GetType().GetProperty("Name").GetValue(st, null) ?? "").ToString();
}
} catch (System.Exception e) { styleName = "<" + e.Message + ">"; }
// location
string loc = "";
try {
var lp = obj.GetType().GetProperty("Location");
if (lp != null) loc = lp.GetValue(obj, null).ToString();
} catch { }
Log(string.Format("[{0}] {1,-20} layer={2,-18} style=\"{3}\" len={4:F2} feat={5} loc={6}",
ent.Handle, cls, ent.Layer, styleName, len, featName, loc));
}
Log("");
Log("segment labels: " + n);
Notes
What worked, what didn't, job-specific gotchas — flagged notes feed the recipes.
No notes yet.