C3D-0247 · 260714 Huckaby: create the 17X11 landscape layout done
Creates layout 17X11, sets ANSI full-bleed B media with 90-degree plot rotation for landscape and monochrome.ctb, then inserts SS_BLOCK_17X11 at the sheet right edge (17.29, 0.29) with all attribute references attached so the title block is fillable. The viewport lives inside the block definition, same as the 11X17 sheet. Bails if the layout already exists.
C# payload
// Create the 17X11 landscape layout and insert SS_BLOCK_17X11.
//
// The block carries its own border AND its own viewport (that is how the 11X17 sheet is built -
// the viewport lives inside the block definition), so the layout only needs the block insert.
// The 11X17 sheet inserts its block at (10.81, 0.29); the block is right-anchored at x=0 and
// grows in -X, so the insert point is the sheet's RIGHT edge. For a 17-wide sheet that is
// x = 17 + a small margin, matching the portrait sheet's 0.29 bottom offset.
var lm = LayoutManager.Current;
if (lm.LayoutExists("17X11")) { Log("layout 17X11 already exists - stopping."); return; }
var bt = (BlockTable)Tx.GetObject(Db.BlockTableId, OpenMode.ForRead);
if (!bt.Has("SS_BLOCK_17X11")) { Log("SS_BLOCK_17X11 missing - run the block ticket first."); return; }
ObjectId layId = lm.CreateLayout("17X11");
var lay = (Layout)Tx.GetObject(layId, OpenMode.ForWrite);
Log("created layout 17X11, tab " + lay.TabOrder);
// ---- plot settings: same media family and pen table as the other sheets, landscape rotation
var psv = PlotSettingsValidator.Current;
try {
psv.SetPlotConfigurationName(lay, "None", null);
} catch (System.Exception e) { Log("plotconfig: " + e.Message); }
string chosen = null;
try {
var medias = psv.GetCanonicalMediaNameList(lay);
// prefer the same ANSI full-bleed B the other sheets use
foreach (string m in medias) {
if (m.IndexOf("ANSI_full_bleed_B", StringComparison.OrdinalIgnoreCase) >= 0) { chosen = m; break; }
}
if (chosen == null) {
foreach (string m in medias) {
if (m.IndexOf("ANSI_B", StringComparison.OrdinalIgnoreCase) >= 0) { chosen = m; break; }
}
}
if (chosen != null) {
psv.SetCanonicalMediaName(lay, chosen);
Log("media: " + chosen);
} else {
Log("no ANSI B media found; leaving default. Available count=" + medias.Count);
}
} catch (System.Exception e) { Log("media: " + e.Message); }
// landscape: rotate the plot 90 so an 11x17 sheet prints 17 wide
try {
psv.SetPlotRotation(lay, PlotRotation.Degrees090);
Log("plot rotation: 90 (landscape)");
} catch (System.Exception e) { Log("rotation: " + e.Message); }
try {
psv.SetPlotType(lay, Autodesk.AutoCAD.DatabaseServices.PlotType.Layout);
psv.SetUseStandardScale(lay, true);
psv.SetStdScaleType(lay, StdScaleType.StdScale1To1);
} catch (System.Exception e) { Log("plottype: " + e.Message); }
try {
psv.SetCurrentStyleSheet(lay, "monochrome.ctb");
Log("pen table: monochrome.ctb");
} catch (System.Exception e) { Log("ctb: " + e.Message); }
// ---- insert the block. Right-anchored at x=0 -> insert at the sheet's right edge.
var sheet = (BlockTableRecord)Tx.GetObject(lay.BlockTableRecordId, OpenMode.ForWrite);
var br = new BlockReference(new Point3d(17.29, 0.29, 0), bt["SS_BLOCK_17X11"]);
br.Layer = "BLOCK_TB2";
sheet.AppendEntity(br);
Tx.AddNewlyCreatedDBObject(br, true);
// pull in the attribute definitions so the title block is fillable
var def = (BlockTableRecord)Tx.GetObject(bt["SS_BLOCK_17X11"], OpenMode.ForRead);
int attrs = 0;
foreach (ObjectId id in def) {
var ad = Tx.GetObject(id, OpenMode.ForRead) as AttributeDefinition;
if (ad == null || ad.Constant) continue;
var ar = new AttributeReference();
ar.SetAttributeFromBlock(ad, br.BlockTransform);
ar.TextString = ad.TextString;
br.AttributeCollection.AppendAttribute(ar);
Tx.AddNewlyCreatedDBObject(ar, true);
attrs++;
}
Log("inserted SS_BLOCK_17X11 at (17.290,0.290) with " + attrs + " attributes");
var back = (BlockReference)Tx.GetObject(br.ObjectId, OpenMode.ForRead);
var e2 = back.GeometricExtents;
Log(string.Format("insert extents ({0:F3},{1:F3})-({2:F3},{3:F3}) {4:F3} x {5:F3} (verified)",
e2.MinPoint.X, e2.MinPoint.Y, e2.MaxPoint.X, e2.MaxPoint.Y,
e2.MaxPoint.X - e2.MinPoint.X, e2.MaxPoint.Y - e2.MinPoint.Y));
Ed.Regen();
Result
Log
created layout 17X11, tab 3 media: ANSI_full_bleed_B plot rotation: 90 (landscape) pen table: monochrome.ctb inserted SS_BLOCK_17X11 at (17.290,0.290) with 13 attributes insert extents (0.290,0.290)-(17.290,11.290) 17.000 x 11.000 (verified)
Notes
What worked, what didn't, job-specific gotchas — flagged notes feed the recipes.
No notes yet.