← Inbox

C3D-VICBOX · Find vicinity map box done

Read-only: geometry in the lower-middle of the 22X17 C sheet around the VICINITY MAP label, plus all viewports, to locate where a map image should be fitted.

Script file
C3D-VICBOX.cs
Target
active document · paper space
Author
claude
Approved
yes · auto-auth
Timeout
60s

C# payload

// READ-ONLY: find the vicinity-map box on 22X17 C. The label "VICINITY MAP (NOT TO SCALE)"
// sits at (8.48,0.53); locate the border geometry around it so an image can be fitted inside.
const string LAYOUT = "22X17 C";
var layDict = (DBDictionary)Tx.GetObject(Db.LayoutDictionaryId, OpenMode.ForRead);
var layout  = (Layout)Tx.GetObject(layDict.GetAt(LAYOUT), OpenMode.ForRead);
var ps      = (BlockTableRecord)Tx.GetObject(layout.BlockTableRecordId, OpenMode.ForRead);

// anything whose extents fall in the lower-middle of the sheet near the label
foreach (ObjectId id in ps)
{
    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 near = ex.MinPoint.X < 13.0 && ex.MaxPoint.X > 6.0 && ex.MinPoint.Y < 5.0;
    if (!near) continue;
    Log(e.GetType().Name + " h=" + e.Handle + " layer='" + e.Layer + "' (" +
        ex.MinPoint.X.ToString("F2") + "," + ex.MinPoint.Y.ToString("F2") + ")-(" +
        ex.MaxPoint.X.ToString("F2") + "," + ex.MaxPoint.Y.ToString("F2") + ")  " +
        (ex.MaxPoint.X-ex.MinPoint.X).ToString("F2") + " x " + (ex.MaxPoint.Y-ex.MinPoint.Y).ToString("F2"));
}

// viewports too - the vicinity map may be a viewport rather than a box
Log("--- viewports ---");
foreach (ObjectId id in ps)
{
    var vp = Tx.GetObject(id, OpenMode.ForRead) as Viewport;
    if (vp == null) continue;
    Log("Viewport h=" + vp.Handle + " num=" + vp.Number + " centre(" + vp.CenterPoint.X.ToString("F2") + "," +
        vp.CenterPoint.Y.ToString("F2") + ") w=" + vp.Width.ToString("F2") + " h=" + vp.Height.ToString("F2") +
        " on='" + vp.On + "' layer='" + vp.Layer + "'");
}

Result

Status
success
Drawing file
C:\Users\sanja\OneDrive\_SurveyDisco\260619 - 3625 Stonewall Tell Rd, Atlanta, GA 30349, USA\260619 - 3625 Stonewall Tell Rd ROTATE.dwg
Message
Executed C3D-VICBOX (0 entities touched).
Entities
Duration
337 ms
Civil 3D
25.0.0.0

Log

Line h=213FF layer='TB1' (11.20,0.33)-(21.76,0.33)  10.57 x 0.00
Viewport h=21534 layer='BLOCK_TB2' (0.30,0.30)-(21.71,16.70)  21.41 x 16.39
DBText h=21544 layer='BLOCK_CLOSURE' (8.49,0.51)-(9.83,0.60)  1.34 x 0.09
BlockReference h=222EB layer='SS-BOUNDARY LAND LOT' (0.25,0.26)-(21.75,16.74)  21.51 x 16.48
--- viewports ---
Viewport h=213FC num=1 centre(16.21,10.22) w=10.46 h=6.09 on='True' layer='0'
Viewport h=21534 num=2 centre(11.00,8.50) w=21.41 h=16.39 on='True' layer='BLOCK_TB2'

Notes

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

No notes yet.