C3D-0327 · Find the 4 bearing labels (408.70 / 79.34 / 1089.00 / 150.35) and what controls their weight [C3D-PSLREAD] done
Read-only. Enumerates every label entity in model space, matches the four distances, reports each one's handle, text, layer, lineweight and label style, plus a style census and the PROP/LABEL layer lineweights.
C# payload
// Find the parcel segment labels carrying 408.70, 79.34, 1089.00, 150.35 and report everything
// that controls their weight: label style, layer, and the style's component lineweight.
Log("drawing: " + Db.Filename);
var targets = new string[] { "408.70", "79.34", "1089.00", "150.35" };
var ms = (BlockTableRecord)Tx.GetObject(SymbolUtilityServices.GetBlockModelSpaceId(Db), OpenMode.ForRead);
int total = 0, hits = 0;
var styleUse = new Dictionary<string,int>();
foreach (ObjectId id in ms) {
var obj = Tx.GetObject(id, OpenMode.ForRead);
string cls = obj.GetType().Name;
if (cls.IndexOf("Label", StringComparison.OrdinalIgnoreCase) < 0) continue;
total++;
var ent = obj as Autodesk.AutoCAD.DatabaseServices.Entity;
if (ent == null) continue;
// pull the label text however it exposes it
string txt = "";
try {
var p = obj.GetType().GetProperty("Text");
if (p != null) txt = (p.GetValue(obj, null) ?? "").ToString();
} catch { }
if (txt.Length == 0) {
try {
var p = obj.GetType().GetProperty("LabelText");
if (p != null) txt = (p.GetValue(obj, null) ?? "").ToString();
} catch { }
}
string styleName = "";
try {
var p = obj.GetType().GetProperty("StyleId");
if (p != null) {
var sid = (ObjectId)p.GetValue(obj, null);
if (!sid.IsNull) {
var st = Tx.GetObject(sid, OpenMode.ForRead);
var np = st.GetType().GetProperty("Name");
if (np != null) styleName = (np.GetValue(st, null) ?? "").ToString();
}
}
} catch { }
string key = cls + " / " + styleName;
if (!styleUse.ContainsKey(key)) styleUse[key] = 0;
styleUse[key]++;
bool match = false;
foreach (var t in targets) if (txt.IndexOf(t, StringComparison.Ordinal) >= 0) match = true;
if (!match) continue;
hits++;
Log(string.Format("HIT [{0}] {1}", ent.Handle, cls));
Log(string.Format(" text : \"{0}\"", txt.Replace("\n"," | ").Replace("\r","")));
Log(string.Format(" layer : {0} lw={1} color={2}", ent.Layer, ent.LineWeight, ent.Color));
Log(string.Format(" style : {0}", styleName));
}
Log("");
Log("label entities in model space: " + total + ", matched: " + hits);
Log("--- label class / style census ---");
foreach (var kv in styleUse) Log(string.Format(" {0,-60} x{1}", kv.Key, kv.Value));
// layer lineweights so we know what a "thin" layer would need
var lt = (LayerTable)Tx.GetObject(Db.LayerTableId, OpenMode.ForRead);
Log("--- layers matching *PROP* or *LABEL* ---");
foreach (ObjectId id in lt) {
var l = (LayerTableRecord)Tx.GetObject(id, OpenMode.ForRead);
if (l.Name.IndexOf("PROP", StringComparison.OrdinalIgnoreCase) < 0 &&
l.Name.IndexOf("LABEL", StringComparison.OrdinalIgnoreCase) < 0) continue;
Log(string.Format(" {0,-32} lw={1,-14} color={2}", l.Name, l.LineWeight, l.Color));
}
Result
Log
drawing: C:\Users\sanja\OneDrive\_SurveyDisco\260714 - 285 Huckaby Rd, Brooks, GA 30205, USA\260714 - 285 Huckaby Rd R2.dwg label entities in model space: 35, matched: 0 --- label class / style census --- GeneralSegmentLabel / x1 ParcelSegmentLabel / x21 NoteLabel / x13 --- layers matching *PROP* or *LABEL* --- C-PROP-BRNG lw=ByLineWeightDefault color=92 C-PROP-TEXT lw=ByLineWeightDefault color=92 C-PROP-LINE lw=ByLineWeightDefault color=230 C-PROP-PATT lw=ByLineWeightDefault color=150 C-PROP-RSRV lw=ByLineWeightDefault color=94 C-PROP-BNDY lw=ByLineWeightDefault color=150 C-PROP-LOTS lw=ByLineWeightDefault color=magenta C-ROAD-PROF-PROP lw=ByLineWeightDefault color=150 C-PROP-LINE-TEXT lw=LineWeight035 color=yellow A-PROP-LINE lw=ByLineWeightDefault color=white C-PROP lw=ByLineWeightDefault color=white SS-PROPOSED-DRIVE lw=ByLineWeightDefault color=white PROPERTY LINES lw=LineWeight080 color=blue X-PROP-CRNR lw=LineWeight025 color=21 SS-PROPOSED lw=LineWeight025 color=10 SS-OUTSITEPROP lw=LineWeight020 color=210 LABELS lw=ByLineWeightDefault color=cyan
Notes
What worked, what didn't, job-specific gotchas — flagged notes feed the recipes.
No notes yet.