← Inbox

C3D-0263 · 260714 Huckaby: fit the 17X11 border inside the printable area done

Full-bleed B is fixed portrait on this machine and rotation does not change it, so a zero-margin landscape sheet is unavailable. Uses the true landscape media ANSI_B_(17.00x11.00) at rotation 0 (paper 17x11, printable 16.50x9.50), scales the SS_BLOCK_17X11 border geometry non-uniformly to 16.50x9.50, and reseats the insert at the printable origin (16.75, 0.75) so nothing clips.

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

C# payload

// Full-bleed B is fixed PORTRAIT 11x17 and rotation does not change the reported paper, so a
// zero-margin landscape sheet is not available on this machine's plot config.
// Use the true landscape media ANSI_B_(17.00_x_11.00_Inches) - paper 17x11, printable 16.50x9.50
// - and REPOSITION the block insert so the 17x11 border sits inside the printable area, matching
// how the portrait sheet has its border inside its own margins.
//
// Printable origin is the lower-left margin corner: 0.25 in from left/right, 0.75 from top/bottom.
// The block is right-anchored (geometry in -X from the insert point), so:
//    insert X = left margin + border width  = 0.25 + 16.50 = 16.75
//    insert Y = bottom margin               = 0.75
// and the border geometry itself must shrink from 17.00x11.00 to the printable 16.50x9.50.
const double PRINT_W = 16.50, PRINT_H = 9.50, MX = 0.25, MY = 0.75;

LayoutManager.Current.CurrentLayout = "17X11";
var bt = (BlockTable)Tx.GetObject(Db.BlockTableId, OpenMode.ForWrite);

// ---- 1. media back to true landscape, no rotation
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;
    psv.SetCanonicalMediaName(lay, "ANSI_B_(17.00_x_11.00_Inches)");
    psv.SetPlotRotation(lay, PlotRotation.Degrees000);
    psv.SetPlotType(lay, Autodesk.AutoCAD.DatabaseServices.PlotType.Layout);
    var b = (Layout)Tx.GetObject(rec.LayoutId, OpenMode.ForRead);
    Log("media: " + b.CanonicalMediaName + " rot=" + b.PlotRotation
        + string.Format(" paper {0:F2}x{1:F2} in", b.PlotPaperSize.X/25.4, b.PlotPaperSize.Y/25.4));
}

// ---- 2. shrink the block's border geometry to the printable area
{
    var def = (BlockTableRecord)Tx.GetObject(bt["SS_BLOCK_17X11"], OpenMode.ForWrite);
    double sx = PRINT_W / 17.0, sy = PRINT_H / 11.0;
    Log(string.Format("scaling block by {0:F4} x {1:F4} to fit the printable area", sx, sy));
    // non-uniform scale about the block origin (0,0)
    var m = Matrix3d.Scaling(sx, Point3d.Origin);      // uniform first
    // AutoCAD Matrix3d has no direct non-uniform scale; build it
    double[] d = { sx,0,0,0,  0,sy,0,0,  0,0,1,0,  0,0,0,1 };
    var nonUniform = new Matrix3d(d);
    int n = 0;
    foreach (ObjectId id in def) {
        var ent = Tx.GetObject(id, OpenMode.ForWrite) as Autodesk.AutoCAD.DatabaseServices.Entity;
        if (ent == null) continue;
        try { ent.TransformBy(nonUniform); n++; } catch (System.Exception e) { Log("  skip " + ent.GetType().Name + ": " + e.Message); }
    }
    double bx0=1e30,by0=1e30,bx1=-1e30,by1=-1e30;
    foreach (ObjectId id in def) {
        var ent = Tx.GetObject(id, OpenMode.ForRead) as Autodesk.AutoCAD.DatabaseServices.Entity;
        if (ent == null) continue;
        double a,bb,c,dd;
        var ad = ent as AttributeDefinition;
        if (ad != null) { a=c=ad.Position.X; bb=dd=ad.Position.Y; }
        else { try { var e=ent.GeometricExtents; a=e.MinPoint.X;bb=e.MinPoint.Y;c=e.MaxPoint.X;dd=e.MaxPoint.Y; } catch { continue; } }
        if (a<bx0)bx0=a; if (bb<by0)by0=bb; if (c>bx1)bx1=c; if (dd>by1)by1=dd;
    }
    Log(string.Format("block transformed ({0} entities): extents ({1:F3},{2:F3})-({3:F3},{4:F3}) = {5:F3} x {6:F3}",
        n, bx0,by0,bx1,by1, bx1-bx0, by1-by0));
}

// ---- 3. reseat the insert at the printable origin
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;
    foreach (ObjectId id in rec) {
        var br = Tx.GetObject(id, OpenMode.ForRead) as BlockReference;
        if (br == null) continue;
        var w = (BlockReference)Tx.GetObject(id, OpenMode.ForWrite);
        w.Position = new Point3d(MX + PRINT_W, MY, 0);
        var e = ((BlockReference)Tx.GetObject(id, OpenMode.ForRead)).GeometricExtents;
        Log(string.Format("insert {0} -> ({1:F3},{2:F3})  ext ({3:F3},{4:F3})-({5:F3},{6:F3}) (verified)",
            w.Name, w.Position.X, w.Position.Y, e.MinPoint.X,e.MinPoint.Y,e.MaxPoint.X,e.MaxPoint.Y));
    }
}
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-0263 (0 entities touched).
Entities
Duration
374 ms
Civil 3D
25.0.0.0

Log

media: ANSI_B_(17.00_x_11.00_Inches) rot=Degrees000 paper 17.00x11.00 in
scaling block by 0.9706 x 0.8636 to fit the printable area
  skip Line: eCannotScaleNonUniformly
  skip Line: eCannotScaleNonUniformly
  skip Line: eCannotScaleNonUniformly
  skip Line: eCannotScaleNonUniformly
  skip Line: eCannotScaleNonUniformly
  skip Line: eCannotScaleNonUniformly
  skip Line: eCannotScaleNonUniformly
  skip Line: eCannotScaleNonUniformly
  skip Line: eCannotScaleNonUniformly
  skip DBText: eCannotScaleNonUniformly
  skip Line: eCannotScaleNonUniformly
  skip Line: eCannotScaleNonUniformly
  skip Line: eCannotScaleNonUniformly
  skip DBText: eCannotScaleNonUniformly
  skip Line: eCannotScaleNonUniformly
  skip DBText: eCannotScaleNonUniformly
  skip Line: eCannotScaleNonUniformly
  skip Line: eCannotScaleNonUniformly
  skip Line: eCannotScaleNonUniformly
  skip Line: eCannotScaleNonUniformly
  skip Line: eCannotScaleNonUniformly
  skip Line: eCannotScaleNonUniformly
  skip Line: eCannotScaleNonUniformly
  skip Line: eCannotScaleNonUniformly
  skip Line: eCannotScaleNonUniformly
  skip Line: eCannotScaleNonUniformly
  skip Line: eCannotScaleNonUniformly
  skip Line: eCannotScaleNonUniformly
  skip Line: eCannotScaleNonUniformly
  skip Line: eCannotScaleNonUniformly
  skip Line: eCannotScaleNonUniformly
  skip Line: eCannotScaleNonUniformly
  skip Line: eCannotScaleNonUniformly
  skip Line: eCannotScaleNonUniformly
  skip Line: eCannotScaleNonUniformly
  skip Line: eCannotScaleNonUniformly
  skip Line: eCannotScaleNonUniformly
  skip Line: eCannotScaleNonUniformly
  skip Line: eCannotScaleNonUniformly
  skip Line: eCannotScaleNonUniformly
  skip Line: eCannotScaleNonUniformly
  skip Line: eCannotScaleNonUniformly
  skip Line: eCannotScaleNonUniformly
  skip Line: eCannotScaleNonUniformly
  skip Line: eCannotScaleNonUniformly
  skip Line: eCannotScaleNonUniformly
  skip Line: eCannotScaleNonUniformly
  skip Line: eCannotScaleNonUniformly
  skip Line: eCannotScaleNonUniformly
  skip Line: eCannotScaleNonUniformly
  skip Line: eCannotScaleNonUniformly
  skip Line: eCannotScaleNonUniformly
  skip Line: eCannotScaleNonUniformly
  skip Line: eCannotScaleNonUniformly
  skip Line: eCannotScaleNonUniformly
  skip Line: eCannotScaleNonUniformly
  skip Line: eCannotScaleNonUniformly
  skip Line: eCannotScaleNonUniformly
  skip Line: eCannotScaleNonUniformly
  skip Line: eCannotScaleNonUniformly
  skip Line: eCannotScaleNonUniformly
  skip Line: eCannotScaleNonUniformly
  skip Line: eCannotScaleNonUniformly
  skip Line: eCannotScaleNonUniformly
  skip Line: eCannotScaleNonUniformly
  skip Line: eCannotScaleNonUniformly
  skip Line: eCannotScaleNonUniformly
  skip Line: eCannotScaleNonUniformly
  skip Line: eCannotScaleNonUniformly
  skip Line: eCannotScaleNonUniformly
  skip Line: eCannotScaleNonUniformly
  skip Line: eCannotScaleNonUniformly
  skip Line: eCannotScaleNonUniformly
  skip Line: eCannotScaleNonUniformly
  skip Line: eCannotScaleNonUniformly
  skip DBText: eCannotScaleNonUniformly
  skip Line: eCannotScaleNonUniformly
  skip Line: eCannotScaleNonUniformly
  skip Line: eCannotScaleNonUniformly
  skip Line: eCannotScaleNonUniformly
  skip Line: eCannotScaleNonUniformly
  skip Line: eCannotScaleNonUniformly
  skip Line: eCannotScaleNonUniformly
  skip Line: eCannotScaleNonUniformly
  skip Line: eCannotScaleNonUniformly
  skip Line: eCannotScaleNonUniformly
  skip DBText: eCannotScaleNonUniformly
  skip DBText: eCannotScaleNonUniformly
  skip DBText: eCannotScaleNonUniformly
  skip DBText: eCannotScaleNonUniformly
  skip Line: eCannotScaleNonUniformly
  skip Line: eCannotScaleNonUniformly
  skip AttributeDefinition: eCannotScaleNonUniformly
  skip AttributeDefinition: eCannotScaleNonUniformly
  skip AttributeDefinition: eCannotScaleNonUniformly
  skip AttributeDefinition: eCannotScaleNonUniformly
  skip AttributeDefinition: eCannotScaleNonUniformly
  skip AttributeDefinition: eCannotScaleNonUniformly
  skip AttributeDefinition: eCannotScaleNonUniformly
  skip AttributeDefinition: eCannotScaleNonUniformly
  skip AttributeDefinition: eCannotScaleNonUniformly
  skip AttributeDefinition: eCannotScaleNonUniformly
  skip AttributeDefinition: eCannotScaleNonUniformly
  skip AttributeDefinition: eCannotScaleNonUniformly
  skip AttributeDefinition: eCannotScaleNonUniformly
block transformed (2 entities): extents (-17.000,0.000)-(0.000,11.000) = 17.000 x 11.000
insert SS_BLOCK_17X11 -> (16.750,0.750)  ext (-0.250,0.750)-(16.750,11.750) (verified)
insert SS_LEGEND -> (16.750,0.750)  ext (13.523,0.968)-(16.227,4.176) (verified)

Notes

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

No notes yet.