C3D-0294 · 260612 C-Store: what the vicinity raster overlaps on 22X17 done
READ-ONLY holistic check. Every entity whose extents intersect the raster, with draw order, so covering vs covered is factual rather than assumed.
C# payload
// HOLISTIC read of 22X17: every pair of entities whose extents OVERLAP, with draw order.
// The question is never "where is X vs the one thing I assumed" - it is "what does X collide
// with on the whole 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 != "22X17") continue;
// collect every entity with extents + its draw-order position
var items = new List<Tuple<ObjectId, string, Extents3d, int>>();
int order = 0;
foreach (ObjectId id in rec) {
var ent = Tx.GetObject(id, OpenMode.ForRead) as Autodesk.AutoCAD.DatabaseServices.Entity;
if (ent == null) continue;
order++;
var vp = ent as Viewport;
if (vp != null) continue; // viewports overlap everything by design
Extents3d e;
try { e = ent.GeometricExtents; } catch { continue; }
string what = ent.GetType().Name;
var dt = ent as DBText; if (dt != null) what = "TEXT \"" + dt.TextString.Substring(0, Math.Min(30, dt.TextString.Length)) + "\"";
var mt = ent as MText; if (mt != null) what = "MTEXT \"" + mt.Contents.Replace("\n", " ").Substring(0, Math.Min(30, mt.Contents.Length)) + "\"";
var br = ent as BlockReference; if (br != null) what = "BLOCK " + br.Name;
var ri = ent as RasterImage; if (ri != null) what = "RASTER";
items.Add(Tuple.Create(id, what, e, order));
}
// the raster(s): what do they cover?
foreach (var a in items) {
if (!a.Item2.StartsWith("RASTER")) continue;
var ra = a.Item3;
Log(string.Format("RASTER [{0}] ({1:F3},{2:F3})-({3:F3},{4:F3}) draw-order {5}",
a.Item1.Handle, ra.MinPoint.X, ra.MinPoint.Y, ra.MaxPoint.X, ra.MaxPoint.Y, a.Item4));
Log(" overlapping entities (draw order > raster = drawn ON TOP of it; < = raster covers them):");
foreach (var b in items) {
if (b.Item1 == a.Item1) continue;
var rb = b.Item3;
bool ox = rb.MinPoint.X < ra.MaxPoint.X && rb.MaxPoint.X > ra.MinPoint.X;
bool oy = rb.MinPoint.Y < ra.MaxPoint.Y && rb.MaxPoint.Y > ra.MinPoint.Y;
if (!ox || !oy) continue;
Log(string.Format(" {0} [{1}] {2,-40} ({3:F3},{4:F3})-({5:F3},{6:F3}) order {7}",
b.Item4 < a.Item4 ? "RASTER-COVERS" : "SITS-ON-RASTER",
b.Item1.Handle, b.Item2, rb.MinPoint.X, rb.MinPoint.Y, rb.MaxPoint.X, rb.MaxPoint.Y, b.Item4));
}
}
}
Result
Log
RASTER [2EC1F] (17.473,9.046)-(21.434,13.007) draw-order 43
overlapping entities (draw order > raster = drawn ON TOP of it; < = raster covers them):
RASTER-COVERS [23273] BLOCK SS_BLOCK_11X17 (0.268,0.230)-(21.777,16.707) order 2Notes
What worked, what didn't, job-specific gotchas — flagged notes feed the recipes.
No notes yet.