← Inbox

C3D-ORIGIN · Find origin junk + true site extents (read-only) done

Identify what sits at 0,0 and report the real geometry extents/centre

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

C# payload

// Read-only: what is sitting at/near (0,0) blowing out the model extents, and where is the
// real geometry clustered? Reports the true site extents excluding origin junk.
var bt = (BlockTable)Tx.GetObject(Db.BlockTableId, OpenMode.ForRead);
var ms = (BlockTableRecord)Tx.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForRead);

int atOrigin = 0;
double minx=double.MaxValue,miny=double.MaxValue,maxx=double.MinValue,maxy=double.MinValue;
foreach (ObjectId id in ms) {
    var e = Tx.GetObject(id, OpenMode.ForRead) as Autodesk.AutoCAD.DatabaseServices.Entity;
    if (e == null) continue;
    Extents3d ex;
    try { ex = e.GeometricExtents; } catch { continue; }
    bool near0 = ex.MinPoint.X < 100000 || ex.MinPoint.Y < 100000;
    if (near0) {
        atOrigin++;
        if (atOrigin <= 15)
            Log($"  NEAR ORIGIN: {e.GetType().Name} layer='{e.Layer}' handle={e.Handle} ext=({ex.MinPoint.X:F1},{ex.MinPoint.Y:F1})-({ex.MaxPoint.X:F1},{ex.MaxPoint.Y:F1})");
        continue;
    }
    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;
}
Log($"entities near origin (junk): {atOrigin}");
Log($"TRUE SITE EXTENTS: ({minx:F2},{miny:F2}) - ({maxx:F2},{maxy:F2})");
Log($"site size: {maxx-minx:F0} x {maxy-miny:F0} ft");
Log($"site centre: ({(minx+maxx)/2:F2}, {(miny+maxy)/2:F2})");

Result

Status
success
Drawing file
C:\Users\sanja\Downloads\GUS.dwg
Message
Executed C3D-ORIGIN (0 entities touched).
Entities
Duration
329 ms
Civil 3D
25.0.0.0

Log

  NEAR ORIGIN: Site layer='0' handle=178EA7 ext=(0.0,0.0)-(0.0,0.0)
  NEAR ORIGIN: GeneralSegmentLabel layer='BOUNDARY' handle=1792C5 ext=(0.0,0.0)-(1.0,0.0)
  NEAR ORIGIN: GeneralSegmentLabel layer='BOUNDARY' handle=1792CD ext=(0.0,0.0)-(1.0,0.0)
  NEAR ORIGIN: GeneralSegmentLabel layer='BOUNDARY' handle=1792CE ext=(0.0,0.0)-(1.0,0.0)
  NEAR ORIGIN: GeneralSegmentLabel layer='BOUNDARY' handle=1792D1 ext=(0.0,0.0)-(1.0,0.0)
  NEAR ORIGIN: GeneralSegmentLabel layer='BOUNDARY' handle=1792D3 ext=(0.0,0.0)-(1.0,0.0)
  NEAR ORIGIN: GeneralSegmentLabel layer='BOUNDARY' handle=1792D4 ext=(0.0,0.0)-(1.0,0.0)
  NEAR ORIGIN: GeneralSegmentLabel layer='BOUNDARY' handle=1792E1 ext=(0.0,0.0)-(1.0,0.0)
  NEAR ORIGIN: GeneralSegmentLabel layer='BOUNDARY' handle=1792E7 ext=(0.0,0.0)-(1.0,0.0)
  NEAR ORIGIN: GeneralSegmentLabel layer='BOUNDARY' handle=1792E8 ext=(0.0,0.0)-(1.0,0.0)
  NEAR ORIGIN: GeneralSegmentLabel layer='BUILDING' handle=1792EE ext=(0.0,0.0)-(1.0,0.0)
  NEAR ORIGIN: GeneralSegmentLabel layer='BOUNDARY' handle=179328 ext=(0.0,0.0)-(1.0,0.0)
  NEAR ORIGIN: GeneralSegmentLabel layer='BOUNDARY' handle=179338 ext=(0.0,0.0)-(1.0,0.0)
  NEAR ORIGIN: GeneralSegmentLabel layer='BOUNDARY' handle=179339 ext=(0.0,0.0)-(1.0,0.0)
entities near origin (junk): 14
TRUE SITE EXTENTS: (2354892.50,1343195.33) - (2384052.49,1392494.24)
site size: 29160 x 49299 ft
site centre: (2369472.50, 1367844.79)

Notes

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

No notes yet.