← Inbox

C3D-PDFGEO · Measure raw PDF block geometry (read-only) done

Get block-definition-space extents and A14/A16 label coords to compute the true transform

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

C# payload

// Read-only: measure the RAW geometry inside the PDF block definition (block-definition space),
// so we can compute the true transform instead of guessing at the block reference.
var bt = (BlockTable)Tx.GetObject(Db.BlockTableId, OpenMode.ForRead);
BlockTableRecord def = null;
foreach (ObjectId id in bt) {
    var b = (BlockTableRecord)Tx.GetObject(id, OpenMode.ForRead);
    if (b.Name.Contains("As Built") || b.Name.Contains("DEV3896")) { def = b; break; }
}
if (def == null) { Log("block def not found"); return; }
Log($"block def '{def.Name}'  origin=({def.Origin.X:F3},{def.Origin.Y:F3})");

double minx=double.MaxValue,miny=double.MaxValue,maxx=double.MinValue,maxy=double.MinValue;
int n=0;
foreach (ObjectId id in def) {
    var e = Tx.GetObject(id, OpenMode.ForRead) as Autodesk.AutoCAD.DatabaseServices.Entity;
    if (e == null) continue;
    try {
        var ex = e.GeometricExtents;
        if (ex.MinPoint.X < minx) minx = ex.MinPoint.X;
        if (ex.MinPoint.Y < miny) miny = ex.MinPoint.Y;
        if (ex.MaxPoint.X > maxx) maxx = ex.MaxPoint.X;
        if (ex.MaxPoint.Y > maxy) maxy = ex.MaxPoint.Y;
        n++;
    } catch { }
}
Log($"raw geometry extents ({n} ents): ({minx:F2},{miny:F2}) - ({maxx:F2},{maxy:F2})");
Log($"raw size: {maxx-minx:F2} x {maxy-miny:F2} units");
Log($"if this is a 24x36 in sheet at 1:1 -> units are inches; sheet pts would be 1728x2592");

// find circles that could be the A14/A16 manhole symbols, and any MText naming them
Log("--- MText containing 'A14' or 'A16' (raw block coords) ---");
foreach (ObjectId id in def) {
    var o = Tx.GetObject(id, OpenMode.ForRead);
    if (o is MText mt) {
        var s = (mt.Contents ?? "").ToUpperInvariant();
        if (s.Contains("A14") || s.Contains("A16") || s.Contains("A12") || s.Contains("A10"))
            Log($"   '{mt.Contents.Trim()}' @({mt.Location.X:F2},{mt.Location.Y:F2}) h={mt.TextHeight:F2}");
    }
}

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-PDFGEO (0 entities touched).
Entities
Duration
372 ms
Civil 3D
25.0.0.0

Log

block def 'As Built - DEV3896 East Lake Pkwy C-Store - Water & Sewer'  origin=(0.000,0.000)
raw geometry extents (10996 ents): (3488938.77,-1062994.13) - (3488955.04,-1062969.97)
raw size: 16.26 x 24.17 units
if this is a 24x36 in sheet at 1:1 -> units are inches; sheet pts would be 1728x2592
--- MText containing 'A14' or 'A16' (raw block coords) ---
   'MH A10' @(3488945.75,-1062981.38) h=0.07
   'MH A12' @(3488946.09,-1062981.57) h=0.07
   'MH A16' @(3488947.01,-1062984.89) h=0.07
   'MH A14' @(3488947.04,-1062983.10) h=0.07

Notes

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

No notes yet.