C3D-VICFIND · Locate VICINITY MAP text in paper space (read-only) error
Find the vicinity map label + any existing raster images so the map can be placed above it
C# payload
// Read-only: locate "VICINITY MAP" text in paper space + report its position/height and the
// empty area above it, so a raster image can be placed correctly.
var bt = (BlockTable)Tx.GetObject(Db.BlockTableId, OpenMode.ForRead);
foreach (ObjectId btrId in bt) {
var btr = (BlockTableRecord)Tx.GetObject(btrId, OpenMode.ForRead);
string where = btr.Name;
if (btr.IsLayout) { var lay = (Layout)Tx.GetObject(btr.LayoutId, OpenMode.ForRead); where = "LAYOUT '" + lay.LayoutName + "'"; }
foreach (ObjectId id in btr) {
var o = Tx.GetObject(id, OpenMode.ForRead);
string s = null;
if (o is MText mt) s = mt.Contents;
else if (o is DBText t) s = t.TextString;
else if (o is BlockReference br && br.AttributeCollection != null) {
foreach (ObjectId aid in br.AttributeCollection) {
var ar = (AttributeReference)Tx.GetObject(aid, OpenMode.ForRead);
if ((ar.TextString ?? "").ToUpperInvariant().Contains("VICINITY")) {
var d2 = (BlockTableRecord)Tx.GetObject(br.DynamicBlockTableRecord, OpenMode.ForRead);
Log($"[{where}] BLOCK '{d2.Name}' ATTR '{ar.Tag}' = \"{ar.TextString}\" @({ar.Position.X:F2},{ar.Position.Y:F2}) h={ar.Height:F2}");
}
}
continue;
}
if (s == null || !s.ToUpperInvariant().Contains("VICINITY")) continue;
var e = (Autodesk.AutoCAD.DatabaseServices.Entity)o;
if (o is MText m2) Log($"[{where}] MText handle={e.Handle} layer={e.Layer} @({m2.Location.X:F3},{m2.Location.Y:F3}) h={m2.TextHeight:F3} attach={m2.Attachment} :: \"{m2.Contents}\"");
else if (o is DBText t2) Log($"[{where}] DBText handle={e.Handle} layer={e.Layer} @({t2.Position.X:F3},{t2.Position.Y:F3}) h={t2.Height:F3} just={t2.Justify} :: \"{t2.TextString}\"");
}
}
// also report existing raster images so we match convention / avoid duplicates
foreach (ObjectId btrId in bt) {
var btr = (BlockTableRecord)Tx.GetObject(btrId, OpenMode.ForRead);
string where = btr.Name;
if (btr.IsLayout) { var lay = (Layout)Tx.GetObject(btr.LayoutId, OpenMode.ForRead); where = "LAYOUT '" + lay.LayoutName + "'"; }
foreach (ObjectId id in btr) {
var o = Tx.GetObject(id, OpenMode.ForRead);
if (o is RasterImage ri) {
var e = (Autodesk.AutoCAD.DatabaseServices.Entity)o;
Log($"[{where}] RASTER handle={e.Handle} layer={e.Layer} name='{ri.ImageDefName}' size=({ri.Width:F2}x{ri.Height:F2})");
}
}
}
Log("Vicinity scan complete.");
Result
Notes
What worked, what didn't, job-specific gotchas — flagged notes feed the recipes.
No notes yet.