← Inbox

C3D-0339 · 17X11: nudge the view down another 60ft - one setback line still in the notch [C3D-PAN2] done

Second pan. C3D-0338 cleared 23 of 24 entities out of the 3x3 notch; one SS-BUFFER SETBACK line still reaches sheet y 8.24. Adds another 60ft (0.30in) to ViewCenter.Y. Viewport frame and scale untouched, verified after the write, then re-projects and recounts what is left in the notch.

Script file
C3D-0339.cs
Target
260714 - 285 Huckaby Rd R3.dwg · paper space
Author
claude
Approved
yes · auto-auth
Timeout
120s

C# payload

// Pan the 17X11 view DOWN so nothing sits in the 3x3 corner notch (sheet x<3, y>8).
// The viewport frame, size and scale are NOT touched - only ViewCenter moves.
//
// Current: ViewCenter (2204922.3227, 1206632.6191), ViewHeight 2051.7701, 1in = 200ft
// Drawing's top-left corner is at sheet (1.09, 8.81); the power easement reaches y 9.62.
// Moving the view UP in model = content moves DOWN on the sheet.
// Need the topmost thing left of x=3 to land below y=8.0 with a little margin.
//
// Second nudge: one SS-BUFFER SETBACK line still reached y 8.24; 60ft = 0.30in clears it.
// ViewCenter.Y increases by 354 to push content down.
const double DY_FT = 60.0;
const double NOTCH_X = 3.0, NOTCH_Y = 8.0;

Log("drawing: " + Db.Filename);
var dict = (DBDictionary)Tx.GetObject(Db.LayoutDictionaryId, OpenMode.ForRead);

foreach (DBDictionaryEntry de in dict) {
    var lay = (Layout)Tx.GetObject(de.Value, OpenMode.ForRead);
    if (lay.LayoutName != "17X11") continue;
    var btr = (BlockTableRecord)Tx.GetObject(lay.BlockTableRecordId, OpenMode.ForRead);

    foreach (ObjectId eid in btr) {
        var probe = Tx.GetObject(eid, OpenMode.ForRead) as Viewport;
        if (probe == null || probe.Number == 1) continue;

        var vp = (Viewport)Tx.GetObject(eid, OpenMode.ForWrite);
        double w = vp.Width, h = vp.Height, vh = vp.ViewHeight;
        var oldC = vp.ViewCenter;
        Log(string.Format("VP [{0}] before: ViewCenter ({1:F4},{2:F4})  ViewHeight {3:F4}  frame {4:F4}x{5:F4}",
            vp.Handle, oldC.X, oldC.Y, vh, w, h));

        bool wasLocked = vp.Locked;
        vp.Locked = false;
        vp.ViewCenter = new Point2d(oldC.X, oldC.Y + DY_FT);
        vp.Locked = wasLocked;

        var back = (Viewport)Tx.GetObject(eid, OpenMode.ForRead);
        Log(string.Format("VP [{0}] after : ViewCenter ({1:F4},{2:F4})  ViewHeight {3:F4}  frame {4:F4}x{5:F4}  locked={6}",
            back.Handle, back.ViewCenter.X, back.ViewCenter.Y, back.ViewHeight,
            back.Width, back.Height, back.Locked));
        if (Math.Abs(back.ViewHeight - vh) > 0.001 || Math.Abs(back.Width - w) > 0.001)
            Log("   !! frame or scale CHANGED - that should not happen");
        else
            Log(string.Format("   scale held at 1in = {0:F2}ft, frame unchanged (verified)", back.ViewHeight/back.Height));
    }
}
Ed.Regen();

// ---- verify: re-project model space through the NEW view and report anything in the notch
foreach (DBDictionaryEntry de in dict) {
    var lay = (Layout)Tx.GetObject(de.Value, OpenMode.ForRead);
    if (lay.LayoutName != "17X11") continue;
    var btr = (BlockTableRecord)Tx.GetObject(lay.BlockTableRecordId, OpenMode.ForRead);
    foreach (ObjectId eid in btr) {
        var vp = Tx.GetObject(eid, OpenMode.ForRead) as Viewport;
        if (vp == null || vp.Number == 1) continue;

        Autodesk.AutoCAD.DatabaseServices.Extents3d fex;
        try { fex = vp.GeometricExtents; } catch { continue; }
        double FX0 = fex.MinPoint.X, FY0 = fex.MinPoint.Y;
        double FW = fex.MaxPoint.X-FX0, FH = fex.MaxPoint.Y-FY0;
        double ftpi = vp.ViewHeight / FH;
        double winW = vp.ViewHeight * (FW/FH);
        double MX0 = vp.ViewCenter.X - winW/2, MY0 = vp.ViewCenter.Y - vp.ViewHeight/2;

        var ms = (BlockTableRecord)Tx.GetObject(SymbolUtilityServices.GetBlockModelSpaceId(Db), OpenMode.ForRead);
        double dX0=1e30,dY0=1e30,dX1=-1e30,dY1=-1e30;
        int bad=0; var worst = new List<string>();
        foreach (ObjectId id in ms) {
            var e = Tx.GetObject(id, OpenMode.ForRead) as Autodesk.AutoCAD.DatabaseServices.Entity;
            if (e == null || e.IsErased || !e.Visible) continue;
            Autodesk.AutoCAD.DatabaseServices.Extents3d ex;
            try { ex = e.GeometricExtents; } catch { continue; }
            double ax=ex.MinPoint.X, ay=ex.MinPoint.Y, bx=ex.MaxPoint.X, by=ex.MaxPoint.Y;
            // skip the bogus site-wide circle and anything absurd
            if ((bx-ax) > 10000 || (by-ay) > 10000) continue;
            if (bx < MX0-2000 || ax > MX0+winW+2000) continue;
            double sx0 = FX0 + (ax-MX0)/ftpi, sy0 = FY0 + (ay-MY0)/ftpi;
            double sx1 = FX0 + (bx-MX0)/ftpi, sy1 = FY0 + (by-MY0)/ftpi;
            dX0=Math.Min(dX0,sx0); dY0=Math.Min(dY0,sy0); dX1=Math.Max(dX1,sx1); dY1=Math.Max(dY1,sy1);
            if (sx0 < NOTCH_X && sy1 > NOTCH_Y) {
                bad++;
                if (worst.Count < 12) worst.Add(string.Format("     [{0}] {1,-18} ({2,6:F2},{3,6:F2})-({4,6:F2},{5,6:F2}) {6}",
                    e.Handle, e.GetType().Name, sx0, sy0, sx1, sy1, e.Layer));
            }
        }
        Log("");
        Log(string.Format("VERIFY: drawing now occupies sheet ({0:F2},{1:F2})-({2:F2},{3:F2})", dX0,dY0,dX1,dY1));
        Log(string.Format("        viewport frame ({0:F2},{1:F2})-({2:F2},{3:F2})", FX0,FY0,FX0+FW,FY0+FH));
        Log(string.Format("        entities still in the notch (x<{0:F1}, y>{1:F1}): {2}", NOTCH_X, NOTCH_Y, bad));
        foreach (var s in worst) Log(s);
        if (dY0 < FY0) Log(string.Format("        !! content runs {0:F2}in below the viewport bottom", FY0-dY0));
        if (dX1 > FX0+FW) Log(string.Format("        !! content runs {0:F2}in past the viewport right", dX1-(FX0+FW)));
    }
}

Result

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

Log

drawing: C:\Users\sanja\OneDrive\_SurveyDisco\260714 - 285 Huckaby Rd, Brooks, GA 30205, USA\260714 - 285 Huckaby Rd R3.dwg
VP [20E73] before: ViewCenter (2204922.3227,1206986.6191)  ViewHeight 2051.7701  frame 16.2551x10.2589
VP [20E73] after : ViewCenter (2204922.3227,1207046.6191)  ViewHeight 2051.7701  frame 16.2551x10.2589  locked=True
   scale held at 1in = 200.00ft, frame unchanged (verified)

VERIFY: drawing now occupies sheet (0.38,3.10)-(27.77,11.54)
        viewport frame (0.37,0.37)-(16.63,10.63)
        entities still in the notch (x<3.0, y>8.0): 0
        !! content runs 11.14in past the viewport right

Notes

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

No notes yet.