C3D-0274 · 260714 Huckaby: check the 17X11 sheet after the users edits done
READ-ONLY. Paper bounds in layout coordinates, the border rectangle lines transformed into sheet coordinates with an on-paper test each, and every entity checked against the paper.
C# payload
// Current state of 17X11: paper bounds, the border rectangle corners, and everything on the sheet.
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 lay = (Layout)Tx.GetObject(rec.LayoutId, OpenMode.ForRead);
if (lay.LayoutName != "17X11") continue;
var m = lay.PlotPaperMargins;
double pw = lay.PlotPaperSize.X/25.4, ph = lay.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(string.Format("PAPER x {0:F3}..{1:F3} y {2:F3}..{3:F3} ({4:F2} x {5:F2} in)", px0,px1,py0,py1,pw,ph));
Log("");
// the block insert + its border rectangle in sheet coords
foreach (ObjectId id in rec) {
var br = Tx.GetObject(id, OpenMode.ForRead) as BlockReference;
if (br == null || br.Name != "SS_BLOCK_17X11") continue;
var xf = br.BlockTransform;
var def = (BlockTableRecord)Tx.GetObject(br.BlockTableRecord, OpenMode.ForRead);
Log(string.Format("insert ({0:F3},{1:F3}) scale ({2:F4},{3:F4})",
br.Position.X, br.Position.Y, br.ScaleFactors.X, br.ScaleFactors.Y));
// find the long border lines
Log("border lines (length > 8 in), in sheet coords:");
foreach (ObjectId oid in def) {
var ln = Tx.GetObject(oid, OpenMode.ForRead) as Line;
if (ln == null) continue;
if (ln.Length < 8.0) continue;
var s = ln.StartPoint.TransformBy(xf);
var e = ln.EndPoint.TransformBy(xf);
bool on = Math.Min(s.X,e.X) >= px0-0.001 && Math.Max(s.X,e.X) <= px1+0.001
&& Math.Min(s.Y,e.Y) >= py0-0.001 && Math.Max(s.Y,e.Y) <= py1+0.001;
Log(string.Format(" [{0}] ({1:F3},{2:F3})->({3:F3},{4:F3}) len {5:F3} onPaper={6}",
ln.Handle, s.X,s.Y,e.X,e.Y, ln.Length, on ? "YES" : "NO"));
}
var be = br.GeometricExtents;
Log(string.Format("block insert extents ({0:F3},{1:F3})-({2:F3},{3:F3})",
be.MinPoint.X,be.MinPoint.Y,be.MaxPoint.X,be.MaxPoint.Y));
}
Log("");
double ax0=1e30,ay0=1e30,ax1=-1e30,ay1=-1e30; int off=0, total=0;
foreach (ObjectId id in rec) {
var ent = Tx.GetObject(id, OpenMode.ForRead) as Autodesk.AutoCAD.DatabaseServices.Entity;
if (ent == null) continue;
var vp = ent as Viewport;
if (vp != null && vp.Number == 1) continue;
total++;
double x0,y0,x1,y1;
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<ax0)ax0=x0; if (y0<ay0)ay0=y0; if (x1>ax1)ax1=x1; if (y1>ay1)ay1=y1;
if (x0 < px0-0.001 || x1 > px1+0.001 || y0 < py0-0.001 || y1 > py1+0.001) {
off++;
string what = ent.GetType().Name;
var br2 = ent as BlockReference; if (br2 != null) what = "BLOCK " + br2.Name;
var mt = ent as MText; if (mt != null) what = "MTEXT \"" + mt.Contents.Replace("\n"," ").Substring(0,Math.Min(25,mt.Contents.Length)) + "\"";
var dt = ent as DBText; if (dt != null) what = "TEXT \"" + dt.TextString + "\"";
if (vp != null) what = "VIEWPORT#" + vp.Number;
if (off <= 20) Log(string.Format("OFF-PAPER [{0}] {1,-36} ({2:F3},{3:F3})-({4:F3},{5:F3}) layer={6}",
ent.Handle, what, x0,y0,x1,y1, ent.Layer));
}
}
Log("");
Log(string.Format("sheet content x {0:F3}..{1:F3} y {2:F3}..{3:F3} entities={4} off-paper={5}",
ax0,ax1,ay0,ay1,total,off));
}
Result
Log
PAPER x -0.250..16.750 y -0.750..10.250 (17.00 x 11.00 in) insert (16.420,-0.420) scale (1.0000,1.0000) border lines (length > 8 in), in sheet coords: [20DEE] (0.121,9.880)->(16.378,9.880) len 16.257 onPaper=YES [20DEF] (0.080,9.920)->(16.420,9.920) len 16.340 onPaper=YES [20DFA] (0.123,2.128)->(9.884,2.128) len 9.760 onPaper=YES [20E3C] (0.121,9.880)->(0.123,-0.379) len 10.259 onPaper=YES [20E3E] (0.123,-0.379)->(16.378,-0.379) len 16.255 onPaper=YES [20E3F] (9.884,2.128)->(0.123,2.128) len 9.760 onPaper=YES [20E40] (16.420,-0.420)->(16.420,9.920) len 10.340 onPaper=YES [20E41] (16.378,-0.379)->(16.378,9.880) len 10.259 onPaper=YES [20E42] (0.080,-0.420)->(16.420,-0.420) len 16.340 onPaper=YES [20E43] (0.080,9.920)->(0.080,-0.420) len 10.340 onPaper=YES block insert extents (0.080,-0.420)-(16.420,9.920) OFF-PAPER [20E70] VIEWPORT#-1 (-1.000,-1.448)-(20.677,11.206) layer=0 OFF-PAPER [20E87] MTEXT "NOTE: PROPERTY LINES SHOW" (18.180,4.804)-(20.823,6.676) layer=BLOCK_NOTES_FLOOD OFF-PAPER [20E88] TEXT "Call FREE" (18.719,3.363)-(19.127,3.420) layer=BLOCK_CLOSURE OFF-PAPER [20E89] TEXT "325-5000" (18.724,3.165)-(19.155,3.222) layer=BLOCK_CLOSURE OFF-PAPER [20E8A] TEXT "UTILITIES PROTECTION CENTER" (18.180,3.459)-(19.921,3.535) layer=BLOCK_CLOSURE OFF-PAPER [20E8B] TEXT "THROUGHOUT GEORGIA" (18.712,3.031)-(19.679,3.088) layer=BLOCK_CLOSURE OFF-PAPER [20E8C] TEXT "IN METRO ATLANTA" (18.727,3.258)-(19.546,3.315) layer=BLOCK_CLOSURE OFF-PAPER [20E8D] TEXT "1-800-282-7411" (18.723,2.939)-(19.483,2.996) layer=BLOCK_CLOSURE OFF-PAPER [20E8E] TEXT "THREE WORKING DAYS BEFORE YOU DIG" (18.194,2.800)-(19.959,2.857) layer=BLOCK_CLOSURE OFF-PAPER [20E8F] Line (18.418,3.092)-(18.418,3.139) layer=BLOCK_CLOSURE OFF-PAPER [20E90] Line (18.426,3.092)-(18.426,3.139) layer=BLOCK_CLOSURE OFF-PAPER [20E91] Line (18.401,3.139)-(18.426,3.139) layer=BLOCK_CLOSURE OFF-PAPER [20E92] Polyline (18.457,3.124)-(18.469,3.135) layer=BLOCK_CLOSURE OFF-PAPER [20E93] Polyline (18.459,3.135)-(18.468,3.292) layer=BLOCK_CLOSURE OFF-PAPER [20E94] Arc (18.355,3.109)-(18.402,3.139) layer=BLOCK_CLOSURE OFF-PAPER [20E95] Line (18.418,3.139)-(18.440,3.139) layer=BLOCK_CLOSURE OFF-PAPER [20E96] Solid (18.398,3.090)-(18.426,3.139) layer=BLOCK_CLOSURE OFF-PAPER [20E97] Solid (18.419,3.090)-(18.442,3.139) layer=BLOCK_CLOSURE OFF-PAPER [20E98] Solid (18.459,3.138)-(18.467,3.292) layer=BLOCK_CLOSURE OFF-PAPER [20E99] Line (18.353,3.316)-(18.402,3.316) layer=BLOCK_CLOSURE sheet content x -1.000..21.035 y -1.448..11.206 entities=138 off-paper=135
Notes
What worked, what didn't, job-specific gotchas — flagged notes feed the recipes.
No notes yet.