← Inbox

C3D-0275 · 260714 Huckaby: switch 17X11 to ANSI full bleed B 17x11 and centre the border done

The paper list does contain a zero-margin landscape sheet, ANSI full bleed B (17.00 x 11.00 Inches) - earlier searches missed it by matching 17.00_x_11.00 with underscores against a canonical name that does not use them. Sets that media at rotation 0, then translates the SS_BLOCK_17X11 insert so its border is centred on the paper, and reports the four margins plus an on-paper test.

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

C# payload

// The paper size list has "ANSI full bleed B (17.00 x 11.00 Inches)" - a zero-margin LANDSCAPE
// sheet. Earlier searches missed it because they matched on "17.00_x_11.00" with underscores
// against a canonical name that does not use them.
// Set it, then move the border + title block so the border sits ON the paper.
LayoutManager.Current.CurrentLayout = "17X11";
Autodesk.AutoCAD.ApplicationServices.Application.SetSystemVariable("TILEMODE", 0);

var bt = (BlockTable)Tx.GetObject(Db.BlockTableId, OpenMode.ForRead);
foreach (ObjectId btrId in bt) {
    var rec = (BlockTableRecord)Tx.GetObject(btrId, OpenMode.ForRead);
    if (!rec.IsLayout) continue;
    var l0 = (Layout)Tx.GetObject(rec.LayoutId, OpenMode.ForRead);
    if (l0.LayoutName != "17X11") continue;
    var lay = (Layout)Tx.GetObject(rec.LayoutId, OpenMode.ForWrite);
    var psv = PlotSettingsValidator.Current;

    // find the full-bleed 17x11 by matching the digits, whatever the separators are
    string best = null;
    foreach (string s in psv.GetCanonicalMediaNameList(lay)) {
        string t = s.ToUpper();
        bool fb = t.Contains("FULL") && t.Contains("BLEED");
        bool b17 = t.Contains("17") && t.Contains("11");
        if (fb && b17) {
            Log("candidate: " + s);
            // prefer the one that reads 17 before 11 (landscape)
            int i17 = t.IndexOf("17"), i11 = t.IndexOf("11");
            if (i17 >= 0 && i11 > i17) { best = s; }
            else if (best == null) best = s;
        }
    }
    if (best == null) { Log("no full-bleed 17x11 found"); return; }

    psv.SetCanonicalMediaName(lay, best);
    psv.SetPlotRotation(lay, PlotRotation.Degrees000);
    psv.SetPlotType(lay, Autodesk.AutoCAD.DatabaseServices.PlotType.Layout);

    var b = (Layout)Tx.GetObject(rec.LayoutId, OpenMode.ForRead);
    var m = b.PlotPaperMargins;
    double pw = b.PlotPaperSize.X/25.4, ph = b.PlotPaperSize.Y/25.4;
    double px0 = -m.MinPoint.X/25.4, py0 = -m.MinPoint.Y/25.4;
    double px1 = px0 + pw, py1 = py0 + ph;
    Log("media -> " + b.CanonicalMediaName + "  rot=" + b.PlotRotation);
    Log(string.Format("paper {0:F3} x {1:F3} in   margins L{2:F3} B{3:F3} R{4:F3} T{5:F3}",
        pw, ph, m.MinPoint.X/25.4, m.MinPoint.Y/25.4, m.MaxPoint.X/25.4, m.MaxPoint.Y/25.4));
    Log(string.Format("PAPER occupies x {0:F3}..{1:F3}   y {2:F3}..{3:F3}", px0, px1, py0, py1));

    // ---- move the title block so its border is centred on the paper
    foreach (ObjectId id in rec) {
        var br = Tx.GetObject(id, OpenMode.ForRead) as BlockReference;
        if (br == null || br.Name != "SS_BLOCK_17X11") continue;
        var e = br.GeometricExtents;
        double bw = e.MaxPoint.X - e.MinPoint.X, bh = e.MaxPoint.Y - e.MinPoint.Y;
        double wantX0 = px0 + (pw - bw) / 2.0;
        double wantY0 = py0 + (ph - bh) / 2.0;
        double dx = wantX0 - e.MinPoint.X, dy = wantY0 - e.MinPoint.Y;
        var w = (BlockReference)Tx.GetObject(id, OpenMode.ForWrite);
        w.TransformBy(Matrix3d.Displacement(new Vector3d(dx, dy, 0)));
        var back = (BlockReference)Tx.GetObject(id, OpenMode.ForRead);
        var e2 = back.GeometricExtents;
        Log(string.Format("title block moved by ({0:F3},{1:F3}) -> ({2:F3},{3:F3})-({4:F3},{5:F3})  {6:F3} x {7:F3}",
            dx, dy, e2.MinPoint.X, e2.MinPoint.Y, e2.MaxPoint.X, e2.MaxPoint.Y, bw, bh));
        Log(string.Format("margins to paper: L{0:F3} B{1:F3} R{2:F3} T{3:F3} (verified)",
            e2.MinPoint.X - px0, e2.MinPoint.Y - py0, px1 - e2.MaxPoint.X, py1 - e2.MaxPoint.Y));
        bool on = e2.MinPoint.X >= px0-0.001 && e2.MaxPoint.X <= px1+0.001
               && e2.MinPoint.Y >= py0-0.001 && e2.MaxPoint.Y <= py1+0.001;
        Log("BORDER ON PAPER: " + (on ? "YES" : "NO"));
    }
}
Ed.Regen();

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

Log

candidate: ANSI_full_bleed_B_(11.00_x_17.00_Inches)
candidate: ANSI_full_bleed_B_(17.00_x_11.00_Inches)
media -> ANSI_full_bleed_B_(17.00_x_11.00_Inches)  rot=Degrees000
paper 17.000 x 11.000 in   margins L0.000 B0.000 R0.000 T0.000
PAPER occupies x -0.000..17.000   y -0.000..11.000
title block moved by (0.250,0.750) -> (0.330,0.330)-(16.670,10.670)  16.340 x 10.340
margins to paper: L0.330 B0.330 R0.330 T0.330 (verified)
BORDER ON PAPER: YES

Notes

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

No notes yet.