C3D-0284 · 260714 Huckaby: locate the VICINITY MAP label on each layout done
READ-ONLY. Finds the VICINITY MAP label, title block extents, and any existing raster or OLE frame on every layout, to place the vicinity map correctly and avoid stacking a duplicate.
C# payload
// Where does the vicinity map go? Find the "VICINITY MAP" label and the title block on every
// layout, plus any raster already attached (idempotency check).
Log("drawing: " + Db.Filename);
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 == "Model") continue;
Log("");
Log("=== " + lay.LayoutName + " ===");
foreach (ObjectId id in rec) {
var ent = Tx.GetObject(id, OpenMode.ForRead) as Autodesk.AutoCAD.DatabaseServices.Entity;
if (ent == null) continue;
var dt = ent as DBText;
if (dt != null && dt.TextString.ToUpper().Contains("VICINITY")) {
var e = dt.GeometricExtents;
Log(string.Format(" LABEL [{0}] \"{1}\" ({2:F4},{3:F4})-({4:F4},{5:F4}) h={6:F3} layer={7}",
dt.Handle, dt.TextString, e.MinPoint.X, e.MinPoint.Y, e.MaxPoint.X, e.MaxPoint.Y, dt.Height, dt.Layer));
}
var mt = ent as MText;
if (mt != null && mt.Contents.ToUpper().Contains("VICINITY")) {
var e = mt.GeometricExtents;
Log(string.Format(" LABEL(M) [{0}] ({1:F4},{2:F4})-({3:F4},{4:F4}) layer={5}",
mt.Handle, e.MinPoint.X, e.MinPoint.Y, e.MaxPoint.X, e.MaxPoint.Y, mt.Layer));
}
var br = ent as BlockReference;
if (br != null) {
var e = br.GeometricExtents;
Log(string.Format(" BLOCK {0,-16} ({1:F4},{2:F4})-({3:F4},{4:F4})", br.Name,
e.MinPoint.X, e.MinPoint.Y, e.MaxPoint.X, e.MaxPoint.Y));
}
var ri = ent as RasterImage;
if (ri != null) {
var e = ri.GeometricExtents;
Log(string.Format(" *** EXISTING RASTER [{0}] ({1:F4},{2:F4})-({3:F4},{4:F4}) layer={5}",
ri.Handle, e.MinPoint.X, e.MinPoint.Y, e.MaxPoint.X, e.MaxPoint.Y, ri.Layer));
}
var ole = ent as Ole2Frame;
if (ole != null) {
var e = ole.GeometricExtents;
Log(string.Format(" *** OLE [{0}] ({1:F4},{2:F4})-({3:F4},{4:F4}) layer={5}",
ole.Handle, e.MinPoint.X, e.MinPoint.Y, e.MaxPoint.X, e.MaxPoint.Y, ole.Layer));
}
}
}
Result
Log
drawing: C:\Users\sanja\OneDrive\_SurveyDisco\260714 - 285 Huckaby Rd, Brooks, GA 30205, USA\260714 - 285 Huckaby Rd R2.dwg === 17X11 === BLOCK SS_BLOCK_17X11 (0.3300,0.3300)-(16.6700,10.6700) LABEL [20EC7] "VICINITY MAP (NOT TO SCALE)" (10.6268,0.5626)-(11.9680,0.6494) h=0.057 layer=BLOCK_CLOSURE BLOCK SS_LEGEND (17.9552,7.0209)-(20.6588,10.2286) BLOCK SCALE200 (12.3136,9.8803)-(16.4217,10.3818) === Layout1 === === 11X17 === BLOCK SS_LEGEND (7.5905,13.3707)-(10.2942,16.5784) LABEL [20955] "VICINITY MAP (NOT TO SCALE)" (0.6579,3.3732)-(1.9990,3.4601) h=0.057 layer=BLOCK_CLOSURE BLOCK SS_BLOCK_11X17 (0.1653,0.2874)-(10.8150,16.7646) === HOUSEDIM === BLOCK Water Valve (0.4486,14.1143)-(0.5600,14.2643) BLOCK Catch Basin (0.4418,14.2826)-(0.5668,14.4076) BLOCK Drainage MH (0.4418,13.9669)-(0.5668,14.0918) BLOCK Existing Hyd (0.4365,13.8140)-(0.5721,13.9390) BLOCK STA (0.4321,13.6599)-(0.5765,13.7849) LABEL [1E807] "VICINITY MAP (NOT TO SCALE)" (1.1841,3.5701)-(2.9723,3.6859) h=0.076 layer=SS-BOUNDARY LAND LOT *** OLE [1E856] (0.4916,3.7472)-(3.8465,6.0957) layer=SS-V-ROAD-CURB
Notes
What worked, what didn't, job-specific gotchas — flagged notes feed the recipes.
No notes yet.