← Inbox

C3D-PDFLAYERS · Full PDF block layer inventory (read-only) rejected

List all 72 layers inside the block with entity counts to decide what to strip

Script file
C3D-PDFLAYERS.cs
Target
active document · model space
Author
claude
Approved
no
Timeout
60s

C# payload

// Read-only: full layer inventory INSIDE the PDF block definition, so we can decide what to
// strip (contours/grading/title block) vs keep (sewer/water/RW/boundary).
var bt = (BlockTable)Tx.GetObject(Db.BlockTableId, OpenMode.ForRead);
BlockTableRecord def = null;
foreach (ObjectId id in bt) {
    var b = (BlockTableRecord)Tx.GetObject(id, OpenMode.ForRead);
    if (b.Name.Contains("As Built") || b.Name.Contains("DEV3896")) { def = b; break; }
}
if (def == null) { Log("block def not found"); return; }
var tally = new Dictionary<string,int>();
int total = 0;
foreach (ObjectId id in def) {
    var e = Tx.GetObject(id, OpenMode.ForRead) as Autodesk.AutoCAD.DatabaseServices.Entity;
    if (e == null) continue;
    total++;
    tally[e.Layer] = tally.TryGetValue(e.Layer, out var n) ? n+1 : 1;
}
Log($"TOTAL entities in block: {total}, layers: {tally.Count}");
foreach (var kv in tally.OrderByDescending(x => x.Value)) Log($"  {kv.Value,6}  {kv.Key}");

Notes

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

No notes yet.