← Inbox

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.

Script file
C3D-TB1SCOPE.cs
Target
active document · model space
Author
claude
Approved
yes · claude (read-only)
Timeout
60s

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

Status
success
Drawing file
C:\Users\sanja\OneDrive\_SurveyDisco\260613 - 5030 E Lake Pkwy, Stockbridge, GA 30281, USA\SS_Outfall_260612_SHEET.dwg
Message
Executed C3D-TB1SCOPE (0 entities touched).
Entities
Duration
421 ms
Civil 3D
25.0.0.0

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.