← Inbox

C3D-0365 · READ-ONLY: full layer table + entity counts + PDF underlays (retry) [C3D-LAYREAD2] done

Retry of C3D-0364 (PdfDefinition has no ActivePage). Full layer table with color/state/description/entity-count, PDF underlay references with source file and layer, and layers whose name contains PDF.

Script file
C3D-0365.cs
Target
260612-Springdale Sanitary Sewer Extension As-Built 60 wPROFILE.dwg · model space
Author
claude
Approved
yes · auto-auth
Timeout
120s

C# payload

// READ-ONLY. Full layer table + entity count per layer, plus any PDF underlays and their layers,
// so we can see what "the pdfx layers" are before merging anything.
Log("drawing: " + Db.Filename);

// count entities per layer across model space
var count = new Dictionary<string,int>();
var ms = (BlockTableRecord)Tx.GetObject(SymbolUtilityServices.GetBlockModelSpaceId(Db), OpenMode.ForRead);
foreach (ObjectId id in ms) {
    var e = Tx.GetObject(id, OpenMode.ForRead) as Autodesk.AutoCAD.DatabaseServices.Entity;
    if (e == null) continue;
    if (!count.ContainsKey(e.Layer)) count[e.Layer]=0;
    count[e.Layer]++;
}

var lt = (LayerTable)Tx.GetObject(Db.LayerTableId, OpenMode.ForRead);
var names = new List<string>();
foreach (ObjectId id in lt) names.Add(((LayerTableRecord)Tx.GetObject(id, OpenMode.ForRead)).Name);
names.Sort(StringComparer.OrdinalIgnoreCase);

Log("=== LAYERS (" + names.Count + ") ===");
foreach (var n in names) {
    var l = (LayerTableRecord)Tx.GetObject(lt[n], OpenMode.ForRead);
    int c = count.ContainsKey(n) ? count[n] : 0;
    Log(string.Format("  {0,-34} color={1,-10} {2,-4}{3} ents={4}  desc=\"{5}\"",
        l.Name, l.Color.ColorNameForDisplay, l.IsFrozen?"FRZ ":"", l.IsOff?"OFF":"", c, l.Description ?? ""));
}

// PDF underlays
Log("");
Log("=== PDF UNDERLAYS ===");
int pdf=0;
foreach (ObjectId id in ms) {
    var u = Tx.GetObject(id, OpenMode.ForRead) as PdfReference;
    if (u == null) continue;
    pdf++;
    Autodesk.AutoCAD.DatabaseServices.Extents3d ex;
    try { ex = u.GeometricExtents; } catch { ex = new Autodesk.AutoCAD.DatabaseServices.Extents3d(); }
    string defName="";
    try { var def=(PdfDefinition)Tx.GetObject(u.DefinitionId, OpenMode.ForRead); defName=def.SourceFileName; } catch {}
    Log(string.Format("  [{0}] PdfReference on layer {1}  ({2:F1},{3:F1})-({4:F1},{5:F1})  src=\"{6}\"",
        u.Handle, u.Layer, ex.MinPoint.X, ex.MinPoint.Y, ex.MaxPoint.X, ex.MaxPoint.Y, defName));
}
if (pdf==0) Log("  none");

// any layer whose name looks pdf-ish
Log("");
Log("=== layers matching *PDF* ===");
foreach (var n in names) if (n.IndexOf("PDF",StringComparison.OrdinalIgnoreCase)>=0)
    Log("  " + n + "  ents=" + (count.ContainsKey(n)?count[n]:0));

Result

Status
success
Drawing file
C:\Users\sanja\OneDrive\_SurveyDisco\260613 - 5030 E Lake Pkwy, Stockbridge, GA 30281, USA\ACAD-260612-Springdale Sanitary Sewer Extension As-Built 60 wPROFILE.dwg
Message
Executed C3D-0365 (0 entities touched).
Entities
Duration
419 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-Springdale Sanitary Sewer Extension As-Built 60 wPROFILE.dwg
=== LAYERS (73) ===
  0                                  color=white           ents=20  desc=""
  AecObjExplode_11X17_Pspace         color=white           ents=0  desc=""
  AecObjExplode_22X17_Pspace         color=white           ents=0  desc=""
  AecObjExplode_22X17_Vport_1D7E     color=white           ents=1  desc=""
  BLOCK_CERT                         color=white           ents=0  desc=""
  BLOCK_CLOSURE                      color=white           ents=0  desc=""
  BLOCK_LEGEND                       color=white           ents=0  desc=""
  BLOCK_NORTH_ARROW                  color=white           ents=0  desc=""
  BLOCK_SCALE                        color=blue            ents=0  desc=""
  BLOCK_TB2                          color=white           ents=0  desc=""
  BOUNDARY                           color=green           ents=0  desc=""
  C-ANNO                             color=white           ents=7  desc=""
  C-PROP-BNDY                        color=150             ents=0  desc=""
  C-PROP-BRNG                        color=92              ents=0  desc=""
  C-PROP-TEXT                        color=92              ents=0  desc=""
  FIRE_HYDRANT                       color=red             ents=4  desc=""
  FIRE_HYDRANT_VALVE                 color=red             ents=3  desc=""
  HORIZONTAL_AND_VERTICAL_CONTROL_POINT color=white           ents=1  desc=""
  PDF2_C-DEMO                        color=green      FRZ  ents=4  desc=""
  PDF2_E GRAVEL                      color=146,146,146 FRZ  ents=427  desc=""
  PDF2_INTER_CONTOURS                color=146,146,146 FRZ  ents=5365  desc=""
  PDF2_P-ESMT                        color=255,255,255 FRZ  ents=3  desc=""
  PDF2_SWM                           color=146,146,146 FRZ  ents=14  desc=""
  PDF2_Text                          color=white           ents=3  desc=""
  PDF2_V-BNDY-ANNO                   color=146,146,146      ents=1  desc=""
  PROF-BAND                          color=8               ents=13  desc=""
  PROF-BORDER                        color=white           ents=4  desc=""
  PROF-GRID                          color=253             ents=33  desc=""
  PROF-GRID-MAJ                      color=8               ents=16  desc=""
  PROF-GROUND                        color=green           ents=6  desc=""
  PROF-MH                            color=blue            ents=28  desc=""
  PROF-PIPE                          color=red             ents=14  desc=""
  PROF-TEXT                          color=white           ents=65  desc=""
  PROF-TITLE                         color=white           ents=3  desc=""
  PROJECT_BOUNDARY_TEXT              color=white      FRZ  ents=10  desc=""
  PROPERTY_LINE                      color=white           ents=29  desc=""
  PUMP_STATION_TEXT                  color=cyan       FRZ  ents=1  desc=""
  ROAD_EDGE_OF_PAVEMENT              color=8               ents=21  desc=""
  ROAD_RIGHT-OF-WAY                  color=magenta         ents=3  desc=""
  SEWER_EASEMENT                     color=green           ents=0  desc=""
  SEWER_EASEMENT RED                 color=red        FRZ  ents=10  desc=""
  SEWER_EASEMENT_20                  color=green      FRZ  ents=0  desc=""
  SEWER_EASEMENT_TEXT                color=green           ents=0  desc=""
  SEWER_LINE                         color=green           ents=6  desc=""
  SEWER_LINE E1                      color=green      FRZ  ents=8  desc=""
  SEWER_LINE_TEXT                    color=94              ents=13  desc=""
  SEWER_LINE_TEXT E1                 color=94         FRZ  ents=17  desc=""
  SEWER_MANHOLE                      color=green           ents=6  desc=""
  SEWER_MANHOLE E1                   color=green      FRZ  ents=7  desc=""
  SEWER_MANHOLE_EXISTING             color=green           ents=1  desc=""
  SEWER_MANHOLE_TEXT                 color=250             ents=16  desc=""
  SEWER_MANHOLE_TEXT E1              color=250        FRZ  ents=16  desc=""
  SS-0-FRAME                         color=cyan       FRZ  ents=41  desc=""
  SS-BOUNDARY                        color=red        FRZ  ents=2  desc=""
  SS-ROAD-BUILDING                   color=magenta         ents=1  desc=""
  SS-ROAD-CANOPY                     color=52              ents=1  desc=""
  SS-ROAD-CL                         color=red             ents=6  desc=""
  SS-ROAD-DUMPSTER                   color=33              ents=1  desc=""
  SS-ROAD-SIDEWALK                   color=cyan            ents=2  desc=""
  SS-ROAD-STRIPE                     color=yellow          ents=40  desc=""
  SS-ROAD-TBC                        color=11         FRZ  ents=75  desc=""
  V-NODE-BNDY                        color=red             ents=0  desc=""
  V-NODE-BORE                        color=red             ents=0  desc=""
  V-NODE-POLE                        color=red             ents=0  desc=""
  V-NODE-STRM                        color=92              ents=0  desc=""
  V-NODE-TEXT                        color=red             ents=0  desc=""
  V-NODE-TREE                        color=62              ents=0  desc=""
  V-NODE-WATR                        color=blue            ents=0  desc=""
  WATER_LINE                         color=blue            ents=2  desc=""
  WATER_LINE_PTS                     color=blue       FRZ  ents=25  desc=""
  WATER_LINE_TEXT                    color=blue            ents=0  desc=""
  WATER_VALVE                        color=cyan            ents=5  desc=""
  WATER_VAULT                        color=blue            ents=4  desc=""

=== PDF UNDERLAYS ===
  none

=== layers matching *PDF* ===
  PDF2_C-DEMO  ents=4
  PDF2_E GRAVEL  ents=427
  PDF2_INTER_CONTOURS  ents=5365
  PDF2_P-ESMT  ents=3
  PDF2_SWM  ents=14
  PDF2_Text  ents=3
  PDF2_V-BNDY-ANNO  ents=1

Notes

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

No notes yet.