← Inbox

C3D-PDFINSP · Inspect PDF import block (read-only) done

Report insertion point, scale, rotation and contents of the imported PDF geometry

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

C# payload

// Read-only: find the PDF import (block ref or loose geometry), report its insertion/scale/rotation
// and what's inside it, so we can verify placement against the A14/A16 control and plan cleanup.
var bt = (BlockTable)Tx.GetObject(Db.BlockTableId, OpenMode.ForRead);
var ms = (BlockTableRecord)Tx.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForRead);

foreach (ObjectId id in ms) {
    var o = Tx.GetObject(id, OpenMode.ForRead);
    if (!(o is BlockReference br)) continue;
    var def = (BlockTableRecord)Tx.GetObject(br.DynamicBlockTableRecord, OpenMode.ForRead);
    Log($"BLOCKREF '{def.Name}' layer={br.Layer}");
    Log($"   insert=({br.Position.X:F3},{br.Position.Y:F3})  scale=({br.ScaleFactors.X:F5},{br.ScaleFactors.Y:F5})  rot={br.Rotation * 180.0 / System.Math.PI:F3} deg");
    var tally = new Dictionary<string,int>();
    var layers = new Dictionary<string,int>();
    int n = 0;
    foreach (ObjectId cid in def) {
        var c = Tx.GetObject(cid, OpenMode.ForRead);
        var ce = c as Autodesk.AutoCAD.DatabaseServices.Entity;
        if (ce == null) continue;
        n++;
        var t = c.GetType().Name;
        tally[t] = tally.TryGetValue(t, out var a) ? a+1 : 1;
        layers[ce.Layer] = layers.TryGetValue(ce.Layer, out var b) ? b+1 : 1;
    }
    Log($"   contents: {n} entities");
    foreach (var kv in tally.OrderByDescending(x => x.Value)) Log($"      {kv.Key}: {kv.Value}");
    Log($"   layers inside ({layers.Count}):");
    foreach (var kv in layers.OrderByDescending(x => x.Value).Take(25)) Log($"      {kv.Key}: {kv.Value}");
    try { var ext = br.GeometricExtents;
        Log($"   extents: ({ext.MinPoint.X:F2},{ext.MinPoint.Y:F2}) - ({ext.MaxPoint.X:F2},{ext.MaxPoint.Y:F2})");
        Log($"   size: {ext.MaxPoint.X-ext.MinPoint.X:F1} x {ext.MaxPoint.Y-ext.MinPoint.Y:F1} ft");
    } catch { Log("   (no extents)"); }
}
// any loose PDF_* layer geometry in model space?
int loose = 0;
foreach (ObjectId id in ms) {
    var e = Tx.GetObject(id, OpenMode.ForRead) as Autodesk.AutoCAD.DatabaseServices.Entity;
    if (e != null && e.Layer.ToUpperInvariant().StartsWith("PDF")) loose++;
}
Log($"loose PDF_* entities in model space: {loose}");

Result

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

Log

BLOCKREF 'As Built - DEV3896 East Lake Pkwy C-Store - Water & Sewer' layer=V-SSWR-MHOL
   insert=(2296379.891,1279953.449)  scale=(1.00000,1.00000)  rot=0.000 deg
   contents: 10996 entities
      Polyline: 10357
      Arc: 287
      MText: 200
      Circle: 108
      Ellipse: 24
      Spline: 20
   layers inside (72):
      PDF_INTER_CONTOURS: 5365
      PDF_INDEX_CONTOURS: 1152
      PDF_C-SIDEWLK-HTC: 477
      PDF_E GRAVEL: 427
      PDF_PGRADE: 408
      PDF_V-BNDY-ANNO: 324
      PDF_V-POWR-OVHD: 280
      PDF_C-CURB-FACE: 246
      PDF_V-ROAD-CURB: 238
      PDF_ae_title-36x24$TBORDER: 228
      PDF_Text: 200
      PDF_V-WATR: 137
      PDF_C-STRIPES: 126
      PDF_C-BLDG-COLS: 120
      PDF_C-SSWR-PIPE: 100
      PDF_ae_title-36x24$T-BD-COPY: 93
      PDF_0-PIPE-SS-A-T: 73
      PDF_GRAPHIC_SCALE: 69
      PDF_C-SSWR-PIPE-PATT: 61
      PDF_V-ROAD-MRKG: 61
      PDF_ae_title-36x24$SEAL2: 59
      PDF_C-WATR-CNTR: 45
      PDF_0-PIPE-STM C: 42
      PDF_V-RIVR-EDGE: 41
      PDF_C-SSWR-LATS: 33
   extents: (5785318.66,216959.32) - (5785334.93,216983.48)
   size: 16.3 x 24.2 ft
loose PDF_* entities in model space: 0

Notes

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

No notes yet.