← Inbox

C3D-0281 · 260714 Huckaby: read the site extents via the active document done

READ-ONLY. Entity counts have been inconsistent across tickets (216/64/37), so this logs the active document name, the script Db filename and whether they are the same object, then measures CogoPoint extents through CivilApplication.ActiveDocument and model space through the active documents database.

Script file
C3D-0281.cs
Target
260714 - 285 Huckaby Rd.dwg · model space
Author
claude
Approved
yes · auto-auth
Timeout
60s

C# payload

// Counts have been inconsistent between tickets (216 / 64 / 37) so read through the ACTIVE
// document explicitly rather than whatever Db resolves to, and log both so they can be compared.
var doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
Log("active doc : " + doc.Name);
Log("script Db  : " + Db.Filename);
Log("same       : " + (doc.Database == Db));

var cdoc = CivilApplication.ActiveDocument;
double px0=1e30,py0=1e30,px1=-1e30,py1=-1e30; int np=0;
foreach (ObjectId id in cdoc.CogoPoints) {
    var p = Tx.GetObject(id, OpenMode.ForRead) as CogoPoint;
    if (p == null) continue;
    np++;
    double x = p.Easting, y = p.Northing;
    if (x<px0)px0=x; if (y<py0)py0=y; if (x>px1)px1=x; if (y>py1)py1=y;
}
Log("");
Log("CogoPoints: " + np);
if (np > 0) {
    Log(string.Format("point extents ({0:F2},{1:F2})-({2:F2},{3:F2}) = {4:F1} x {5:F1} ft",
        px0,py0,px1,py1,px1-px0,py1-py0));
    double need = Math.Max((px1-px0)/16.34, (py1-py0)/10.34);
    Log(string.Format("fits the 16.34 x 10.34 border at 1\"={0:F1}'", need));
    foreach (double s in new double[]{20,30,40,50,60,100}) {
        Log(string.Format("   1\"={0,3:F0}' covers {1:F0} x {2:F0} ft   fits={3}",
            s, 16.34*s, 10.34*s, (px1-px0)<=16.34*s && (py1-py0)<=10.34*s ? "YES" : "no"));
    }
}
Log("");
// walk model space via the active document's database
var db = doc.Database;
var bt2 = (BlockTable)Tx.GetObject(db.BlockTableId, OpenMode.ForRead);
var ms2 = (BlockTableRecord)Tx.GetObject(bt2[BlockTableRecord.ModelSpace], OpenMode.ForRead);
int n2 = 0; double mx0=1e30,my0=1e30,mx1=-1e30,my1=-1e30;
foreach (ObjectId id in ms2) {
    var ent = Tx.GetObject(id, OpenMode.ForRead) as Autodesk.AutoCAD.DatabaseServices.Entity;
    if (ent == null) continue;
    n2++;
    double a,b,c,d;
    try { var e = ent.GeometricExtents; a=e.MinPoint.X;b=e.MinPoint.Y;c=e.MaxPoint.X;d=e.MaxPoint.Y; } catch { continue; }
    if (Math.Abs(a)<1.0 && Math.Abs(b)<1.0) continue;
    if (a<mx0)mx0=a; if (b<my0)my0=b; if (c>mx1)mx1=c; if (d>my1)my1=d;
}
Log("model space via active doc: " + n2 + " entities");
Log(string.Format("   extents ({0:F2},{1:F2})-({2:F2},{3:F2}) = {4:F1} x {5:F1} ft", mx0,my0,mx1,my1,mx1-mx0,my1-my0));

Result

Status
success
Drawing file
C:\Users\sanja\OneDrive\_SurveyDisco\260714 - 285 Huckaby Rd, Brooks, GA 30205, USA\260714 - 285 Huckaby Rd.dwg
Message
Executed C3D-0281 (0 entities touched).
Entities
Duration
373 ms
Civil 3D
25.0.0.0

Log

active doc : C:\Users\sanja\OneDrive\_SurveyDisco\260714 - 285 Huckaby Rd, Brooks, GA 30205, USA\260714 - 285 Huckaby Rd.dwg
script Db  : C:\Users\sanja\OneDrive\_SurveyDisco\260714 - 285 Huckaby Rd, Brooks, GA 30205, USA\260714 - 285 Huckaby Rd.dwg
same       : True

CogoPoints: 151
point extents (2203403.96,1206804.91)-(2206424.23,1207403.37) = 3020.3 x 598.5 ft
fits the 16.34 x 10.34 border at 1"=184.8'
   1"= 20' covers 327 x 207 ft   fits=no
   1"= 30' covers 490 x 310 ft   fits=no
   1"= 40' covers 654 x 414 ft   fits=no
   1"= 50' covers 817 x 517 ft   fits=no
   1"= 60' covers 980 x 620 ft   fits=no
   1"=100' covers 1634 x 1034 ft   fits=no

model space via active doc: 37 entities
   extents (-2.02,0.00)-(2.09,0.25) = 4.1 x 0.2 ft

Notes

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

No notes yet.