C3D-0340 · 17X11: verify the pan - visible footprint, anything crossing the frame edge, layers in view [C3D-CHK] done
Read-only. Re-projects only VISIBLE model space (skipping frozen/off layers) through the current 17X11 view, reports the real content footprint on the sheet, lists entities crossing the viewport frame edge, and censuses which layers are actually in view.
C# payload
// What is the drawing's real footprint now, and what is the thing sticking out to sheet x=27.77?
const double NOTCH_X = 3.0, NOTCH_Y = 8.0;
Log("drawing: " + Db.Filename);
var dict = (DBDictionary)Tx.GetObject(Db.LayoutDictionaryId, OpenMode.ForRead);
foreach (DBDictionaryEntry de in dict) {
var lay = (Layout)Tx.GetObject(de.Value, OpenMode.ForRead);
if (lay.LayoutName != "17X11") continue;
var btr = (BlockTableRecord)Tx.GetObject(lay.BlockTableRecordId, OpenMode.ForRead);
foreach (ObjectId eid in btr) {
var vp = Tx.GetObject(eid, OpenMode.ForRead) as Viewport;
if (vp == null || vp.Number == 1) continue;
Autodesk.AutoCAD.DatabaseServices.Extents3d fex;
try { fex = vp.GeometricExtents; } catch { continue; }
double FX0=fex.MinPoint.X, FY0=fex.MinPoint.Y;
double FW=fex.MaxPoint.X-FX0, FH=fex.MaxPoint.Y-FY0;
double ftpi = vp.ViewHeight/FH, winW = vp.ViewHeight*(FW/FH);
double MX0 = vp.ViewCenter.X-winW/2, MY0 = vp.ViewCenter.Y-vp.ViewHeight/2;
Log(string.Format("frame ({0:F2},{1:F2})-({2:F2},{3:F2}) 1in={4:F1}ft", FX0,FY0,FX0+FW,FY0+FH, ftpi));
var ms = (BlockTableRecord)Tx.GetObject(SymbolUtilityServices.GetBlockModelSpaceId(Db), OpenMode.ForRead);
// everything VISIBLE in the frame window, by layer
var lay2 = new Dictionary<string,int>();
double pX0=1e30,pY0=1e30,pX1=-1e30,pY1=-1e30;
var outside = new List<string>();
foreach (ObjectId id in ms) {
var e = Tx.GetObject(id, OpenMode.ForRead) as Autodesk.AutoCAD.DatabaseServices.Entity;
if (e == null || e.IsErased || !e.Visible) continue;
// is the layer frozen/off?
var ltr = (LayerTableRecord)Tx.GetObject(e.LayerId, OpenMode.ForRead);
if (ltr.IsFrozen || ltr.IsOff) continue;
Autodesk.AutoCAD.DatabaseServices.Extents3d ex;
try { ex = e.GeometricExtents; } catch { continue; }
double ax=ex.MinPoint.X, ay=ex.MinPoint.Y, bx=ex.MaxPoint.X, by=ex.MaxPoint.Y;
double sx0=FX0+(ax-MX0)/ftpi, sy0=FY0+(ay-MY0)/ftpi;
double sx1=FX0+(bx-MX0)/ftpi, sy1=FY0+(by-MY0)/ftpi;
// only things actually visible through the frame
if (sx1 < FX0 || sx0 > FX0+FW || sy1 < FY0 || sy0 > FY0+FH) continue;
if (!lay2.ContainsKey(e.Layer)) lay2[e.Layer]=0;
lay2[e.Layer]++;
pX0=Math.Min(pX0,sx0); pY0=Math.Min(pY0,sy0); pX1=Math.Max(pX1,sx1); pY1=Math.Max(pY1,sy1);
if (sx1 > FX0+FW+0.01 || sx0 < FX0-0.01 || sy1 > FY0+FH+0.01 || sy0 < FY0-0.01)
if (outside.Count < 15)
outside.Add(string.Format(" [{0}] {1,-18} ({2,7:F2},{3,7:F2})-({4,7:F2},{5,7:F2}) {6}",
e.Handle, e.GetType().Name, sx0,sy0,sx1,sy1, e.Layer));
}
Log(string.Format("VISIBLE content footprint: ({0:F2},{1:F2})-({2:F2},{3:F2})", pX0,pY0,pX1,pY1));
Log("--- entities crossing the frame edge ---");
foreach (var s in outside) Log(s);
Log(" (showing up to 15)");
Log("--- visible layers in view ---");
foreach (var kv in lay2) Log(string.Format(" {0,-30} x{1}", kv.Key, kv.Value));
}
}
Result
Log
drawing: C:\Users\sanja\OneDrive\_SurveyDisco\260714 - 285 Huckaby Rd, Brooks, GA 30205, USA\260714 - 285 Huckaby Rd R3.dwg frame (0.37,0.37)-(16.63,10.63) 1in=200.0ft VISIBLE content footprint: (-43.05,-28.14)-(31.33,46.24) --- entities crossing the frame edge --- [1A9D7] Circle ( -43.05, -28.14)-( 31.33, 46.24) SS-FLOW WELL (showing up to 15) --- visible layers in view --- SS-FLOW WELL x1 0 x16 SS-V-POWER-CL x4 SS-V-ROAD-CNTR x2 SS-V-ROAD-EPVM x5 X-DRIV-CONC x5 SS-V-WALK x1 V-STRC-WALL x8 SS-V-BLDG-OTLN x15 SS-X-FENCE x2 SS-BOUNDARY MAG x1 SS-BOUNDARY CYAN x2 V-NODE-TEXT x2 SS-BUFFER SETBACK x10 C-PROP-LINE x7 C-PROP x1 C-PROP-LINE-TEXT x9 C-ANNO x13 SS-BOUNDARY x3 SS-V-POWER-EASEMENT x14
Notes
What worked, what didn't, job-specific gotchas — flagged notes feed the recipes.
No notes yet.