C3D-0108 · READ-ONLY: the fire hydrant and valve entities and their colours [FH-READ] done
Lists every entity on FIRE_HYDRANT, FIRE_HYDRANT_VALVE and WATER_VALVE with its type, colour override and position, to find why four entities show as three and why they render blue while the layer is red. No changes.
C# payload
// READ-ONLY. The 4 FIRE_HYDRANT entities: what they are, their colour and where they sit.
// User sees only 3 and they render blue despite the layer being red - so at least one carries a
// hardcoded colour override, and one may be coincident with another.
var ms = (BlockTableRecord)Tx.GetObject(SymbolUtilityServices.GetBlockModelSpaceId(Db), OpenMode.ForRead);
var lt = (LayerTable)Tx.GetObject(Db.LayerTableId, OpenMode.ForRead);
Log("drawing: " + Db.Filename);
foreach (string nm in new string[] { "FIRE_HYDRANT", "FIRE_HYDRANT_VALVE", "WATER_VALVE" }) {
if (!lt.Has(nm)) { Log(nm + ": layer missing"); continue; }
var l = (LayerTableRecord)Tx.GetObject(lt[nm], OpenMode.ForRead);
Log("");
Log("=== " + nm + " layerColor=" + l.Color + " ===");
foreach (ObjectId id in ms) {
Autodesk.AutoCAD.DatabaseServices.DBObject o;
try { o = Tx.GetObject(id, OpenMode.ForRead); } catch { continue; }
var ent = o as Autodesk.AutoCAD.DatabaseServices.Entity;
if (ent == null) continue;
string lay; try { lay = ent.Layer; } catch { continue; }
if (lay != nm) continue;
string where = "";
var cp = o as CogoPoint;
if (cp != null) where = String.Format("pt {0} \"{1}\" at {2:F2},{3:F2}", cp.PointNumber, cp.RawDescription, cp.Easting, cp.Northing);
var br = o as BlockReference;
if (br != null) where = String.Format("block {0} at {1:F2},{2:F2}", br.Name, br.Position.X, br.Position.Y);
Log(String.Format(" [{0}] {1,-16} color={2,-10} {3}", o.Handle, o.GetType().Name, ent.Color, where));
}
}
Result
Log
drawing: C:\Users\sanja\OneDrive\_SurveyDisco\260613 - 5030 E Lake Pkwy, Stockbridge, GA 30281, USA\260612 - CSTORE WATER ABS 30.dwg === FIRE_HYDRANT layerColor=red === [237E9] CogoPoint color=BYLAYER pt 408 "FH" at 2296542.17,1280022.08 [23846] CogoPoint color=BYLAYER pt 502 "FH" at 2296377.46,1280101.20 [23869] CogoPoint color=BYLAYER pt 537 "FH" at 2296431.32,1280258.58 [238D8] CogoPoint color=BYLAYER pt 1115 "FH" at 2296377.44,1280101.12 === FIRE_HYDRANT_VALVE layerColor=red === [237EA] CogoPoint color=BYLAYER pt 409 "WV" at 2296543.09,1280020.37 [2386B] CogoPoint color=BYLAYER pt 539 "WV" at 2296434.20,1280260.93 [238D9] CogoPoint color=BYLAYER pt 1116 "WV" at 2296376.28,1280101.54 === WATER_VALVE layerColor=cyan === [23821] CogoPoint color=BYLAYER pt 465 "WV" at 2296380.20,1280018.52 [23845] CogoPoint color=BYLAYER pt 501 "WV" at 2296376.17,1280101.61 [2384B] CogoPoint color=BYLAYER pt 507 "WV" at 2296390.79,1280253.34 [2384D] CogoPoint color=BYLAYER pt 509 "WV" at 2296394.32,1280257.26 [238DA] CogoPoint color=BYLAYER pt 1117 "WV" at 2296380.29,1280018.48
Notes
What worked, what didn't, job-specific gotchas — flagged notes feed the recipes.
No notes yet.