C3D-0008 · Find VICINITY MAP label + existing rasters [VIC-FIND] done
Read-only: the VICINITY MAP label position/extents on every layout, and any raster or OLE already placed, to size and position a vicinity map per the title-block-fill recipe.
C# payload
// READ-ONLY: locate the VICINITY MAP label on every layout and report the free space above it,
// plus any raster already placed, so a map can be sized and positioned per the title-block-fill
// recipe (2.30in square, on the label's x, 0.075in gap above it, layer BLOCK_CLOSURE).
var layDict = (DBDictionary)Tx.GetObject(Db.LayoutDictionaryId, OpenMode.ForRead);
foreach (DBDictionaryEntry de in layDict)
{
var lay = (Layout)Tx.GetObject(de.Value, OpenMode.ForRead);
var ps = (BlockTableRecord)Tx.GetObject(lay.BlockTableRecordId, OpenMode.ForRead);
Log("=== '" + lay.LayoutName + "' paper " + (lay.PlotPaperSize.X/25.4).ToString("F2") + " x " +
(lay.PlotPaperSize.Y/25.4).ToString("F2") + " in");
foreach (ObjectId id in ps)
{
var e = Tx.GetObject(id, OpenMode.ForRead) as Autodesk.AutoCAD.DatabaseServices.Entity;
if (e == null) continue;
string t = null; double x = 0, y = 0, h = 0;
var mt = e as MText; if (mt != null) { t = mt.Contents; x = mt.Location.X; y = mt.Location.Y; h = mt.TextHeight; }
var dt = e as DBText; if (dt != null) { t = dt.TextString; x = dt.Position.X; y = dt.Position.Y; h = dt.Height; }
if (t != null && t.ToUpper().Contains("VICINITY"))
{
var ex = e.GeometricExtents;
Log(" LABEL '" + t.Replace("\u005CP"," | ") + "' layer='" + e.Layer + "' h=" + h.ToString("F3"));
Log(" at (" + x.ToString("F2") + "," + y.ToString("F2") + ") extents (" +
ex.MinPoint.X.ToString("F2") + "," + ex.MinPoint.Y.ToString("F2") + ")-(" +
ex.MaxPoint.X.ToString("F2") + "," + ex.MaxPoint.Y.ToString("F2") + ")");
}
if (e is RasterImage) {
var ex = e.GeometricExtents;
Log(" RASTER already present h=" + e.Handle + " layer='" + e.Layer + "' (" +
ex.MinPoint.X.ToString("F2") + "," + ex.MinPoint.Y.ToString("F2") + ")-(" +
ex.MaxPoint.X.ToString("F2") + "," + ex.MaxPoint.Y.ToString("F2") + ")");
}
if (e is Ole2Frame) {
var ex = e.GeometricExtents;
Log(" OLE already present h=" + e.Handle + " layer='" + e.Layer + "' (" +
ex.MinPoint.X.ToString("F2") + "," + ex.MinPoint.Y.ToString("F2") + ")-(" +
ex.MaxPoint.X.ToString("F2") + "," + ex.MaxPoint.Y.ToString("F2") + ")");
}
}
}
Result
Log
=== '11X17' paper 11.00 x 17.00 in
=== '22X17' paper 22.00 x 17.00 in
LABEL 'VICINITY MAP (NOT TO SCALE)' layer='BLOCK_CLOSURE' h=0.057
at (9.04,0.45) extents (9.05,0.43)-(10.39,0.52)
=== 'Model' paper 17.00 x 11.00 in
RASTER already present h=2B0C8 layer='PDF2_GENERAL-TEXT' (2297036.65,1277126.35)-(2297326.45,1277246.54)Notes
What worked, what didn't, job-specific gotchas — flagged notes feed the recipes.
No notes yet.