← Inbox

C3D-0101 · READ-ONLY: what is on the boundary layers [BND-READ] done

Lists every layer whose name contains BOUNDARY or BNDY with its colour, linetype and state, and every entity sitting on those layers with vertex counts, lengths, closure and area. No changes.

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

C# payload

// READ-ONLY. Everything on any layer whose name contains BOUNDARY, with what each entity is.
var lt = (LayerTable)Tx.GetObject(Db.LayerTableId, OpenMode.ForRead);
var bt = (BlockTable)Tx.GetObject(Db.BlockTableId, OpenMode.ForRead);
Log("drawing: " + Db.Filename);
Log("");

Log("=== BOUNDARY layers in the layer table ===");
var names = new HashSet<string>();
foreach (ObjectId lid in lt) {
    var l = (LayerTableRecord)Tx.GetObject(lid, OpenMode.ForRead);
    if (l.Name.ToUpper().IndexOf("BOUNDARY") < 0 && l.Name.ToUpper().IndexOf("BNDY") < 0) continue;
    names.Add(l.Name);
    Log(String.Format("  {0,-32} color={1} lt={2}{3}{4}{5}", l.Name, l.Color,
        l.LinetypeObjectId.IsNull ? "?" : ((LinetypeTableRecord)Tx.GetObject(l.LinetypeObjectId, OpenMode.ForRead)).Name,
        l.IsOff ? "  OFF" : "", l.IsFrozen ? "  FROZEN" : "", l.IsLocked ? "  LOCKED" : ""));
}

Log("");
Log("=== entities on those layers ===");
foreach (ObjectId btrId in bt) {
    var btr = (BlockTableRecord)Tx.GetObject(btrId, OpenMode.ForRead);
    foreach (ObjectId id in btr) {
        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 (!names.Contains(lay)) continue;

        string extra = "";
        var pl = o as Polyline;
        if (pl != null) extra = String.Format(" verts={0} len={1:F2} closed={2} area={3:F2}",
            pl.NumberOfVertices, pl.Length, pl.Closed, pl.Closed ? pl.Area : 0.0);
        var ln = o as Line;   if (ln != null) extra = String.Format(" len={0:F2}", ln.Length);
        var mt = o as MText;  if (mt != null) extra = " \"" + mt.Contents + "\"";
        var br = o as BlockReference; if (br != null) extra = " block=" + br.Name;
        var pc = o as Parcel; if (pc != null) extra = " parcel=\"" + pc.Name + "\" area=" + pc.Area.ToString("F2");

        Log(String.Format("  [{0}] {1,-18} {2,-24} in {3}{4}",
            o.Handle, o.GetType().Name, lay, btr.IsLayout ? btr.Name : "BLOCKDEF " + btr.Name, extra));
    }
}

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-0101 (0 entities touched).
Entities
Duration
612 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

=== BOUNDARY layers in the layer table ===
  V-NODE-BNDY                      color=red lt=Continuous
  C-PROP-BNDY                      color=150 lt=Continuous
  SS-BOUNDARY                      color=red lt=Continuous  FROZEN
  BOUNDARY                         color=green lt=DBLDASH

=== entities on those layers ===
  [17DA] Polyline           SS-BOUNDARY              in *Model_Space verts=27 len=2871.31 closed=True area=36239.95
  [17DD] Polyline           SS-BOUNDARY              in *Model_Space verts=27 len=2871.31 closed=True area=36239.95
  [1B0A] Polyline3d         C-PROP-BNDY              in *Model_Space
  [1F40] Polyline           BOUNDARY                 in *Paper_Space14 verts=21 len=1.39 closed=False area=0.00
  [1F44] Polyline           BOUNDARY                 in *Paper_Space14 verts=15 len=0.70 closed=False area=0.00
  [1F45] Polyline           BOUNDARY                 in *Paper_Space14 verts=16 len=0.92 closed=False area=0.00
  [1F46] Polyline           BOUNDARY                 in *Paper_Space14 verts=93 len=3.39 closed=False area=0.00
  [180D] BlockReference     V-NODE-BNDY              in BLOCKDEF *U16 block=Iron Pin
  [195C] BlockReference     V-NODE-BNDY              in BLOCKDEF *U59 block=Iron Pin
  [1A46] BlockReference     V-NODE-BNDY              in BLOCKDEF *U71 block=Iron Pin
  [1ACB] BlockReference     V-NODE-BNDY              in BLOCKDEF *U90 block=Iron Pin
  [1AD1] BlockReference     V-NODE-BNDY              in BLOCKDEF *U91 block=Iron Pin
  [1AD7] BlockReference     V-NODE-BNDY              in BLOCKDEF *U92 block=Iron Pin
  [1ADD] BlockReference     V-NODE-BNDY              in BLOCKDEF *U93 block=Iron Pin
  [1AE3] BlockReference     V-NODE-BNDY              in BLOCKDEF *U94 block=Iron Pin

Notes

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

No notes yet.