C3D-0244 · 260714 Huckaby: create SS_BLOCK_17X11 (landscape, title panel bottom left) done
Deep-clones SS_BLOCK_11X17 to a new SS_BLOCK_17X11 and reshapes it to 17x11 landscape: border lines restretched to the new width/height, the viewport resized to the area above the title panel, and the title panel plus flood note slid left so they sit in the bottom-left corner. The original block is untouched so the 11X17 layout keeps working. Bails if SS_BLOCK_17X11 already exists. Verifies block extents and panel position on read-back.
C# payload
// Build SS_BLOCK_17X11: a LANDSCAPE 17 x 11 copy of SS_BLOCK_11X17 with the title panel in the
// BOTTOM LEFT. The original block is untouched - the 11X17 layout still uses it.
//
// Geometry facts read from the drawing (C3D-0243):
// original border outer 0..-10.650 x 0..16.477, inner -0.043..-10.610 x 0.043..16.434
// title panel x -10.198..-0.041, y 0.043..2.710 (already a full-width bottom strip)
// viewport 20AD6 -10.610..-0.043 x 0.043..16.434
// the block is RIGHT-ANCHORED at x=0 and grows in -X, so widening to 17 extends LEFT.
// That would leave the panel on the RIGHT, so the panel is then shifted -6.759 to sit hard
// in the bottom-left corner.
//
// Handles below are from the ORIGINAL block; after Clone() they are new objects, so entities are
// matched by their geometry instead (a clone does not preserve handles).
const double W = 17.0, H = 11.0; // landscape sheet
const double IN = 0.043; // inner border inset, as built
const double PANEL_W = 10.157; // -10.198 .. -0.041
const double PANEL_TOP = 2.710;
const double DX_PANEL = -(W - 0.043 - PANEL_W - 0.043) + 0.0; // slide panel to the left edge
var bt = (BlockTable)Tx.GetObject(Db.BlockTableId, OpenMode.ForWrite);
if (!bt.Has("SS_BLOCK_11X17")) { Log("source block missing"); return; }
if (bt.Has("SS_BLOCK_17X11")) { Log("SS_BLOCK_17X11 already exists - stopping so nothing is clobbered."); return; }
var src = (BlockTableRecord)Tx.GetObject(bt["SS_BLOCK_11X17"], OpenMode.ForRead);
// ---- clone the definition
var dst = new BlockTableRecord();
dst.Name = "SS_BLOCK_17X11";
dst.Origin = src.Origin;
bt.Add(dst);
Tx.AddNewlyCreatedDBObject(dst, true);
var ids = new ObjectIdCollection();
foreach (ObjectId id in src) ids.Add(id);
var map = new IdMapping();
Db.DeepCloneObjects(ids, dst.ObjectId, map, false);
Log("cloned " + ids.Count + " entities into SS_BLOCK_17X11");
// ---- classify + transform the clones
double panelShift = -(W - PANEL_W - 2 * IN); // how far left the panel must travel
int stretched = 0, movedPanel = 0, vpDone = 0;
foreach (ObjectId id in dst) {
var ent = Tx.GetObject(id, OpenMode.ForWrite) as Autodesk.AutoCAD.DatabaseServices.Entity;
if (ent == null) continue;
// --- the viewport: resize to the area above the title panel
var vp = ent as Viewport;
if (vp != null) {
double vx0 = -(W - IN), vx1 = -IN, vy0 = PANEL_TOP, vy1 = H - IN;
vp.Width = vx1 - vx0;
vp.Height = vy1 - vy0;
vp.CenterPoint = new Point3d((vx0 + vx1) / 2.0, (vy0 + vy1) / 2.0, 0);
vpDone++;
Log(string.Format("viewport -> center ({0:F3},{1:F3}) size {2:F3} x {3:F3}",
vp.CenterPoint.X, vp.CenterPoint.Y, vp.Width, vp.Height));
continue;
}
// --- decide: is this a border line, or part of the title panel / notes?
double x0, y0, x1, y1;
var ad = ent as AttributeDefinition;
if (ad != null) { x0 = x1 = ad.Position.X; y0 = y1 = ad.Position.Y; }
else {
try { var e = ent.GeometricExtents; x0=e.MinPoint.X; y0=e.MinPoint.Y; x1=e.MaxPoint.X; y1=e.MaxPoint.Y; }
catch { continue; }
}
var ln = ent as Line;
bool isBorder = false;
if (ln != null) {
bool fullH = Math.Abs(y1 - y0) > 6.0; // spans most of the sheet height
bool fullW = Math.Abs(x1 - x0) > 10.0; // spans the full sheet width
bool atTop = Math.Abs(y0 - 16.477) < 0.01 || Math.Abs(y0 - 16.434) < 0.01;
bool atBottom = Math.Abs(y0) < 0.001 && Math.Abs(y1) < 0.001;
bool atLeft = Math.Abs(x0 + 10.650) < 0.01 || Math.Abs(x0 + 10.610) < 0.01;
bool atRight = Math.Abs(x1) < 0.001 || Math.Abs(x1 + 0.043) < 0.01;
isBorder = fullH || (fullW && (atTop || atBottom)) || (atLeft && fullH) || (atRight && fullH);
if (isBorder) {
var s = ln.StartPoint; var e2 = ln.EndPoint;
Func<Point3d, Point3d> remap = p => {
double nx = p.X, ny = p.Y;
// left edges travel out to the new width
if (Math.Abs(p.X + 10.650) < 0.01) nx = -W;
else if (Math.Abs(p.X + 10.610) < 0.01) nx = -(W - IN);
// top edges drop to the new height
if (Math.Abs(p.Y - 16.477) < 0.01) ny = H;
else if (Math.Abs(p.Y - 16.434) < 0.01) ny = H - IN;
else if (p.Y > PANEL_TOP + 0.01) ny = Math.Min(p.Y, H - IN); // interior verticals
return new Point3d(nx, ny, p.Z);
};
ln.StartPoint = remap(s);
ln.EndPoint = remap(e2);
stretched++;
continue;
}
}
// --- everything at/below the panel top is title-block content: slide it left
if (y1 <= PANEL_TOP + 0.60) { // +0.60 keeps the flood note (y up to 3.10) with it
ent.TransformBy(Matrix3d.Displacement(new Vector3d(panelShift, 0, 0)));
movedPanel++;
}
}
Log(string.Format("border lines restretched: {0} panel entities moved by dx={1:F3}: {2} viewports: {3}",
stretched, panelShift, movedPanel, vpDone));
// ---- verify
double bx0=1e30, by0=1e30, bx1=-1e30, by1=-1e30;
double px0=1e30, py0=1e30, px1=-1e30, py1=-1e30;
foreach (ObjectId id in dst) {
var ent = Tx.GetObject(id, OpenMode.ForRead) as Autodesk.AutoCAD.DatabaseServices.Entity;
if (ent == null || ent is Viewport) continue;
double x0,y0,x1,y1;
var ad = ent as AttributeDefinition;
if (ad != null) { x0=x1=ad.Position.X; y0=y1=ad.Position.Y; }
else { try { var e=ent.GeometricExtents; x0=e.MinPoint.X;y0=e.MinPoint.Y;x1=e.MaxPoint.X;y1=e.MaxPoint.Y; } catch { continue; } }
if (x0<bx0) bx0=x0; if (y0<by0) by0=y0; if (x1>bx1) bx1=x1; if (y1>by1) by1=y1;
if (y1 <= PANEL_TOP + 0.60) { if (x0<px0) px0=x0; if (y0<py0) py0=y0; if (x1>px1) px1=x1; if (y1>py1) py1=y1; }
}
Log(string.Format("BLOCK extents ({0:F3},{1:F3})-({2:F3},{3:F3}) = {4:F3} x {5:F3} (want 17.000 x 11.000)",
bx0, by0, bx1, by1, bx1-bx0, by1-by0));
Log(string.Format("TITLE PANEL ({0:F3},{1:F3})-({2:F3},{3:F3}) left edge should be near {4:F3} (verified)",
px0, py0, px1, py1, -(W - IN)));
Ed.Regen();
Result
Log
cloned 109 entities into SS_BLOCK_17X11 viewport -> center (-8.500,6.834) size 16.914 x 8.247 border lines restretched: 7 panel entities moved by dx=-6.757: 100 viewports: 1 BLOCK extents (-17.000,0.000)-(0.000,16.477) = 17.000 x 16.477 (want 17.000 x 11.000) TITLE PANEL (-17.000,0.000)-(0.000,3.104) left edge should be near -16.957 (verified)
Notes
What worked, what didn't, job-specific gotchas — flagged notes feed the recipes.
No notes yet.