C3D-TB1SCOPE · Scope TB1 layer usage drawing-wide (read-only) done
Is TB1 only the 2 orphaned lines, or used on other layouts/model? Determines if freeze is safe.
C# payload
// READ-ONLY: is layer TB1 used ANYWHERE besides the 2 orphaned lines on 11X17? (model + all layouts)
using System;
using System.Collections.Generic;
using Autodesk.AutoCAD.DatabaseServices;
var db = Db;
using (var tr = db.TransactionManager.StartTransaction())
{
var bt = (BlockTable)tr.GetObject(db.BlockTableId, OpenMode.ForRead);
var counts = new SortedDictionary<string,int>(StringComparer.OrdinalIgnoreCase);
foreach (ObjectId btrId in bt)
{
var btr = (BlockTableRecord)tr.GetObject(btrId, OpenMode.ForRead);
// where does this block live: model, a paperspace layout, or a block def?
string space = btr.IsLayout ? btr.Name : "(blockdef:" + btr.Name + ")";
foreach (ObjectId id in btr)
{
var e = tr.GetObject(id, OpenMode.ForRead) as Autodesk.AutoCAD.DatabaseServices.Entity;
if (e == null || !string.Equals(e.Layer, "TB1", StringComparison.OrdinalIgnoreCase)) continue;
var key = $"{space} :: {e.GetType().Name}";
counts[key] = counts.TryGetValue(key, out var c) ? c+1 : 1;
}
}
Log("Layer TB1 usage across the drawing:");
if (counts.Count == 0) Log(" (none)");
foreach (var kv in counts) Log($" {kv.Value}x {kv.Key}");
tr.Commit();
}
Result
Log
Layer TB1 usage across the drawing: 2x (blockdef:A$C6bff6bd2) :: Line 2x *Paper_Space :: Line
Notes
What worked, what didn't, job-specific gotchas — flagged notes feed the recipes.
No notes yet.