← Inbox

C3D-0109 · 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.

Script file
C3D-0109.cs
Target
active document · model space
Author
claude
Approved
yes · reviewer
Timeout
180s

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

Status
success
Drawing file
C:\Users\sanja\OneDrive\_SurveyDisco\260613 - 5030 E Lake Pkwy, Stockbridge, GA 30281, USA\ACAD-260612 - CSTORE WATER ABS 30.dwg
Message
Executed C3D-0109 (0 entities touched).
Entities
Duration
370 ms
Civil 3D
25.0.0.0

Log

drawing: C:\Users\sanja\OneDrive\_SurveyDisco\260613 - 5030 E Lake Pkwy, Stockbridge, GA 30281, USA\ACAD-260612 - CSTORE WATER ABS 30.dwg

=== FIRE_HYDRANT  layerColor=red ===
  [18B5] BlockReference   color=BYLAYER    block *U40 at 2296542.17,1280022.08
  [194C] BlockReference   color=BYLAYER    block *U57 at 2296377.46,1280101.20
  [1A49] BlockReference   color=BYLAYER    block *U72 at 2296431.32,1280258.58
  [1A7D] BlockReference   color=BYLAYER    block *U80 at 2296377.44,1280101.12

=== FIRE_HYDRANT_VALVE  layerColor=red ===
  [18C8] BlockReference   color=BYLAYER    block *U41 at 2296543.09,1280020.37
  [1A56] BlockReference   color=BYLAYER    block *U74 at 2296434.20,1280260.93
  [1A82] BlockReference   color=BYLAYER    block *U81 at 2296376.28,1280101.54

=== WATER_VALVE  layerColor=cyan ===
  [18F9] BlockReference   color=BYLAYER    block *U46 at 2296380.20,1280018.52
  [1965] BlockReference   color=BYLAYER    block *U61 at 2296390.79,1280253.34
  [196A] BlockReference   color=BYLAYER    block *U62 at 2296394.32,1280257.26
  [1A87] BlockReference   color=BYLAYER    block *U82 at 2296380.29,1280018.48

Notes

What worked, what didn't, job-specific gotchas — flagged notes feed the recipes.

No notes yet.