← Inbox

C3D-0045 · READ-ONLY: the 29 used non-PDF non-C- layers [READ-KEEP-LAYERS] done

Same inventory, printing only layers that actually hold entities: KEEP = used and not PDF*/C-* (the filter membership), excl = used but excluded by the PDF/C- rule. No changes.

Script file
C3D-0045.cs
Target
260612 · model space
Author
claude
Approved
yes · reviewer
Timeout
240s

C# payload

// READ-ONLY. Full inventory of 260612 - CSTORE WATER ABS 30.dwg.
//
// Purpose: (a) know every layer and whether it is actually USED, so a filter can be built for
// used-only excluding PDF* and C-*, and (b) know what entity types sit on each layer so the
// "is everything on the correct layer" audit has real data behind it.
// Nothing is modified.
var lt = (LayerTable)Tx.GetObject(Db.LayerTableId, OpenMode.ForRead);

// layer -> type -> count, across model space AND all layouts/blocks
var used = new Dictionary<string, Dictionary<string,int>>();
var bt = (BlockTable)Tx.GetObject(Db.BlockTableId, OpenMode.ForRead);

Action<string,string> bump = (lay, tn) => {
    if (!used.ContainsKey(lay)) used[lay] = new Dictionary<string,int>();
    if (!used[lay].ContainsKey(tn)) used[lay][tn] = 0;
    used[lay][tn]++;
};

int totalEnts = 0;
foreach (ObjectId btrId in bt) {
    var btr = (BlockTableRecord)Tx.GetObject(btrId, OpenMode.ForRead);
    // count only model space + layouts as "used"; block DEFINITION contents are counted separately
    bool isLayoutOrModel = btr.IsLayout;
    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;
        totalEnts++;
        if (isLayoutOrModel) bump(ent.Layer, o.GetType().Name);
    }
}

Log("=== LAYERS (" + "used in model/layouts" + ") ===");
var names = new List<string>();
foreach (ObjectId lid in lt) {
    var l = (LayerTableRecord)Tx.GetObject(lid, OpenMode.ForRead);
    names.Add(l.Name);
}
names.Sort();

int nUsed = 0, nEmpty = 0, nKeep = 0;
foreach (var nm in names) {
    var l = (LayerTableRecord)Tx.GetObject(lt[nm], OpenMode.ForRead);
    int cnt = 0; var parts = new List<string>();
    if (used.ContainsKey(nm)) {
        foreach (var kv in used[nm]) { cnt += kv.Value; parts.Add(kv.Key + ":" + kv.Value); }
    }
    if (cnt > 0) nUsed++; else nEmpty++;

    string up = nm.ToUpper();
    bool excluded = up.StartsWith("PDF") || up.StartsWith("C-");
    bool keep = cnt > 0 && !excluded;
    if (keep) nKeep++;

    if (keep || (cnt > 0 && excluded))
        Log(String.Format("{0} {1,-34} n={2,-5} {3}{4}{5}  [{6}]",
            keep ? "KEEP" : "excl", nm, cnt,
            l.IsOff ? "OFF " : "", l.IsFrozen ? "FROZEN " : "", l.IsLocked ? "LOCKED " : "",
            String.Join(" ", parts)));
}

Log("");
Log("layers total=" + names.Count + "  used=" + nUsed + "  empty=" + nEmpty);
Log("USED and not PDF*/C-* (filter members) = " + nKeep);
Log("entities scanned across all BTRs: " + totalEnts);

Result

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

Log

=== LAYERS (used in model/layouts) ===
KEEP 0                                  n=529     [CogoPoint:524 PdfReference:1 Viewport:3 BlockReference:1]
KEEP BLOCK_CLOSURE                      n=35      [MText:3 DBText:8 Line:12 Polyline:4 Arc:1 Solid:4 Polyline2d:2 RasterImage:1]
KEEP BLOCK_NORTH_ARROW                  n=101     [Line:90 Polyline2d:8 DBText:1 Arc:2]
excl C-ANNO                             n=3       [NoteLabel:3]
excl C-ANNO-CERT                        n=3       [MText:3]
excl C-ANNO-CERT-LINE                   n=9       [Line:9]
excl C-ANNO-TABL-TTBL                   n=5       [Site:5]
excl C-PROP                             n=3       [Parcel:3]
excl C-PROP-LINE                        n=4       [ParcelSegment:4]
excl C-PROP-LINE-TEXT                   n=8       [ParcelSegmentLabel:8]
excl C-PROP-TABL                        n=2       [ParcelSegmentTable:2]
excl PDF2_0-ALIGN-SDL2-T                n=31      [Polyline:31]
excl PDF2_0-PIPE-EX SS                  n=1       [Polyline:1]
excl PDF2_0-PIPE-SS-A                   n=31      [Hatch:1 Polyline:11 Arc:16 Circle:3]
excl PDF2_0-PIPE-SS-A-T                 n=93      [Hatch:10 Solid:10 Polyline:45 Arc:28]
excl PDF2_0-PIPE-STM A                  n=32      [Polyline:32]
excl PDF2_0-PIPE-STM B                  n=32      [Polyline:32]
excl PDF2_0-PIPE-STM C                  n=42      [Arc:36 Circle:4 Polyline:2]
excl PDF2_2015_Flood_Map_DFIRM          n=3       [Polyline:3]
excl PDF2_ae_title-36x24$SEAL           n=37      [Hatch:16 Polyline:18 Circle:3]
excl PDF2_ae_title-36x24$SEAL2          n=59      [Polyline:40 Arc:19]
excl PDF2_ae_title-36x24$T-BD-COPY      n=469     [Hatch:377 Polyline:87 Ellipse:5]
excl PDF2_ae_title-36x24$T-BD-INFO1     n=88      [Hatch:85 Polyline:3]
excl PDF2_ae_title-36x24$T-BD-INFO2     n=27      [Polyline:27]
excl PDF2_ae_title-36x24$T-BD-LINE      n=13      [Hatch:10 Polyline:3]
excl PDF2_ae_title-36x24$T-BD-LOGO      n=84      [Hatch:72 Polyline:8 Arc:4]
excl PDF2_ae_title-36x24$T-BD-PROJ      n=113     [Hatch:101 Polyline:12]
excl PDF2_ae_title-36x24$T-BD-PROJ2     n=19      [Polyline:19]
excl PDF2_ae_title-36x24$TBORDER        n=228     [Polyline:226 Ellipse:2]
excl PDF2_ae_title-36x24$TITLE          n=45      [Hatch:15 Polyline:19 Arc:11]
excl PDF2_C-ANNO                        n=25      [Solid:12 Polyline:13]
excl PDF2_C-BLDG-COLS                   n=120     [Polyline:112 Arc:8]
excl PDF2_C-CONC                        n=15      [Polyline:10 Circle:5]
excl PDF2_C-CURB-FACE                   n=246     [Polyline:166 Arc:80]
excl PDF2_C-DEMO                        n=4     FROZEN   [Hatch:4]
excl PDF2_C-ESMT-BLDG-SBAK              n=12      [Hatch:2 Polyline:10]
excl PDF2_C-ESMT-BLDG-SBAK-ANNO         n=2       [Hatch:2]
excl PDF2_C-SIDEWALKS                   n=8       [Hatch:2 Polyline:6]
excl PDF2_C-SIDEWLK-HTC                 n=477     [Polyline:477]
excl PDF2_C-SIGNS                       n=4       [Polyline:2 Circle:2]
excl PDF2_C-SSWR-LATS                   n=33      [Polyline:25 Circle:8]
excl PDF2_C-SSWR-PIPE                   n=100     [Polyline:88 Circle:12]
excl PDF2_C-SSWR-PIPE-PATT              n=71      [Solid:10 Polyline:35 Arc:6 Spline:20]
excl PDF2_C-SSWR-STRC-PATT              n=35      [Solid:11 Polyline:19 Arc:3 Circle:2]
excl PDF2_C-STRIPES                     n=129     [Hatch:3 Polyline:103 Arc:10 Circle:13]
excl PDF2_C-STRM-CNTR                   n=94      [Hatch:69 Polyline:23 Circle:2]
excl PDF2_C-WATR-ANNO                   n=29      [Polyline:29]
excl PDF2_C-WATR-CNTR                   n=45      [Polyline:45]
excl PDF2_C-WATR-STRC                   n=17      [Hatch:1 Polyline:16]
excl PDF2_C-WATR-TEXT                   n=14      [Hatch:1 Solid:6 Polyline:7]
excl PDF2_E CONCRETE                    n=2       [Polyline:1 Arc:1]
excl PDF2_E EDGE PVMT                   n=2       [Polyline:2]
excl PDF2_E FENCE                       n=5       [Polyline:5]
excl PDF2_E GRAVEL                      n=427   FROZEN   [Polyline:427]
excl PDF2_E IPF-SET                     n=40      [Polyline:5 Circle:35]
excl PDF2_E POWER                       n=23      [Polyline:23]
excl PDF2_E STORM                       n=7       [Polyline:7]
excl PDF2_E STORM TEXT                  n=17      [Polyline:16 Ellipse:1]
excl PDF2_E WALL                        n=2       [Polyline:2]
excl PDF2_ESMT v2                       n=15      [Hatch:7 Polyline:8]
excl PDF2_GENERAL-TEXT                  n=4       [RasterImage:1 Hatch:1 Polyline:2]
excl PDF2_GRAPHIC_SCALE                 n=70      [Hatch:1 Polyline:68 Circle:1]
excl PDF2_INDEX_CONTOURS                n=1152    [Polyline:1152]
excl PDF2_INTER_CONTOURS                n=5365  FROZEN   [Polyline:5365]
excl PDF2_Level 3                       n=2       [Circle:2]
excl PDF2_NOTES                         n=1       [Polyline:1]
excl PDF2_P-ESMT                        n=3     FROZEN   [Hatch:2 Polyline:1]
excl PDF2_P-RW                          n=3       [Hatch:2 Polyline:1]
excl PDF2_P-Setbacks                    n=1       [Polyline:1]
excl PDF2_PGRADE                        n=417     [Hatch:9 Polyline:408]
excl PDF2_REVISIONS                     n=3       [Arc:1 Polyline:2]
excl PDF2_SWM                           n=14    FROZEN   [Polyline:12 Circle:2]
excl PDF2_SWM-TXT                       n=1       [Hatch:1]
excl PDF2_Text                          n=203     [MText:203]
excl PDF2_TXT200                        n=62      [Hatch:62]
excl PDF2_V-BNDY                        n=35      [Polyline:5 Arc:4 Line:26]
excl PDF2_V-BNDY-ANNO                   n=329     [Solid:5 Polyline:311 Circle:10 Ellipse:3]
excl PDF2_V-ESMT                        n=3       [Polyline:3]
excl PDF2_V-POWR-OVHD                   n=280     [Polyline:259 Circle:9 Ellipse:12]
excl PDF2_V-RIVR-EDGE                   n=41      [Polyline:41]
excl PDF2_V-ROAD-CURB                   n=239     [Hatch:1 Polyline:217 Arc:20 Circle:1]
excl PDF2_V-ROAD-MRKG                   n=61      [Polyline:39 Arc:22]
excl PDF2_V-SSWR                        n=16      [Polyline:16]
excl PDF2_V-SSWR-ANNO                   n=10      [Solid:2 Polyline:5 Arc:2 Circle:1]
excl PDF2_V-STRM-GRAT                   n=18      [Arc:18]
excl PDF2_V-STRM-STRC-TEXT              n=14      [Solid:1 Polyline:13]
excl PDF2_V-WATR                        n=137     [Polyline:135 Circle:2]
KEEP PROPERTY_LINE                      n=1       [Polyline:1]
KEEP ROAD_EDGE_OF_PAVEMENT              n=13      [Polyline:5 Line:7 Hatch:1]
KEEP ROAD_RIGHT-OF-WAY                  n=9       [Line:3 Polyline:1 MText:4 BlockReference:1]
KEEP SEWER_EASEMENT                     n=3       [Site:1 Polyline:2]
KEEP SEWER_EASEMENT_20                  n=1     FROZEN   [ParcelSegment:1]
KEEP SEWER_EASEMENT_TEXT                n=29      [ParcelSegmentLabel:29]
KEEP SEWER_LINE                         n=14      [Line:14]
KEEP SEWER_LINE_TEXT                    n=28      [MText:28]
KEEP SEWER_MANHOLE                      n=13      [CogoPoint:13]
KEEP SEWER_MANHOLE_EXISTING             n=1       [CogoPoint:1]
KEEP SEWER_MANHOLE_TEXT                 n=26      [MText:21 Leader:5]
KEEP SS-0-FRAME                         n=21    FROZEN   [CogoPoint:14 Polyline:5 MText:2]
KEEP SS-BOUNDARY                        n=6       [Site:2 Polyline:2 Parcel:1 BlockReference:1]
KEEP SS-BOUNDARY LAND LOT               n=1       [MText:1]
KEEP SS-ROAD-BUILDING                   n=1       [Polyline:1]
KEEP SS-ROAD-CANOPY                     n=1       [Polyline:1]
KEEP SS-ROAD-CL                         n=4       [Polyline:3 Line:1]
KEEP SS-ROAD-DUMPSTER                   n=1       [Polyline:1]
KEEP SS-ROAD-GUARDRAIL                  n=1       [Polyline:1]
KEEP SS-ROAD-SIDEWALK                   n=2       [Polyline:2]
KEEP SS-ROAD-STRIPE                     n=42      [Polyline:42]
KEEP SS-ROAD-TBC                        n=77      [Polyline:55 Arc:8 Line:14]
KEEP V-CTRL-LINE-SHOT                   n=2       [Leader:2]
KEEP V-CTRL-TEXT                        n=2       [MText:2]
KEEP WATER_VALVE                        n=12      [CogoPoint:12]
KEEP WATER_VAULT                        n=2       [Polyline:2]

layers total=486  used=113  empty=373
USED and not PDF*/C-* (filter members) = 29
entities scanned across all BTRs: 29679

Notes

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

No notes yet.