C3D-0149 · Vicinity map raster on the 11X17 sheet [VIC-260802] done
Attaches the Google Static Maps vicinity PNG (fetched for the job coordinates and saved beside the drawing) as a raster in paper space, 2.30 inches square, left-aligned to the VICINITY MAP label and sitting just above it, inside the title block frame. Raster not OLE, matching the method that worked on 260612. Idempotent and verifies the placement is within the frame.
C# payload
// Attach the Google Static Maps vicinity image on *Paper_Space, above the
// "VICINITY MAP (NOT TO SCALE)" label (DBText 20955, position 0.6524,3.3922, paper inches).
//
// Image fetched from the Google Static Maps API using the job's own coordinates
// (33.6427815,-84.35829199999999 from the SurveyDisco card's streetViewUrl) and saved next to the
// drawing. This is the C-Store method: a RASTER pressed onto the page, not an OLE link - the OLE
// attempt on 260612 (C3D-VICOLE) errored, the raster worked.
//
// Placement: left edge aligned to the label, sitting just above it, 2.30" square. The title block
// spans x 0.165-10.815 / y 0.287-16.765, so the image stays well inside the frame.
// Idempotent: bails if a raster is already attached in paper space.
const string IMGNAME = "260802-vicinity";
string path = @"C:\Users\sanja\OneDrive\_SurveyDisco\260802 - 4082 Sweetbriar Ln, Forest Park, GA 30297, USA\260802-vicinity.png";
if (!System.IO.File.Exists(path)) { Log("ABORT: image not found: " + path); return; }
Log("image: " + path + " (" + new System.IO.FileInfo(path).Length + " bytes)");
var bt = (BlockTable)Tx.GetObject(Db.BlockTableId, OpenMode.ForRead);
var psId = bt[BlockTableRecord.PaperSpace];
var ps = (BlockTableRecord)Tx.GetObject(psId, OpenMode.ForRead);
foreach (ObjectId id in ps) {
var ri = Tx.GetObject(id, OpenMode.ForRead) as RasterImage;
if (ri != null && !ri.IsErased) { Log("a raster is already in paper space - skipping (idempotent)"); return; }
}
var dictId = RasterImageDef.GetImageDictionary(Db);
if (dictId.IsNull) dictId = RasterImageDef.CreateImageDictionary(Db);
var dict = (DBDictionary)Tx.GetObject(dictId, OpenMode.ForWrite);
ObjectId defId;
if (dict.Contains(IMGNAME)) defId = dict.GetAt(IMGNAME);
else {
var def = new RasterImageDef();
def.SourceFileName = path;
def.Load();
defId = dict.SetAt(IMGNAME, def);
Tx.AddNewlyCreatedDBObject(def, true);
}
double w = 2.30, h = 2.30;
double x0 = 0.6524; // label's own left edge
double y0 = 3.4601 + 0.06; // just above the label's top
var img = new RasterImage();
img.ImageDefId = defId;
img.Orientation = new CoordinateSystem3d(new Point3d(x0, y0, 0), new Vector3d(w, 0, 0), new Vector3d(0, h, 0));
img.Layer = "BLOCK_CLOSURE";
img.ShowImage = true;
var psW = (BlockTableRecord)Tx.GetObject(psId, OpenMode.ForWrite);
psW.AppendEntity(img);
Tx.AddNewlyCreatedDBObject(img, true);
RasterImage.EnableReactors(true);
img.AssociateRasterDef((RasterImageDef)Tx.GetObject(defId, OpenMode.ForWrite));
var chk = (RasterImage)Tx.GetObject(img.ObjectId, OpenMode.ForRead);
var e = chk.GeometricExtents;
Log(String.Format("vicinity map attached [{0}] layer={1}", chk.Handle, chk.Layer));
Log(String.Format(" extents {0:F3},{1:F3} -> {2:F3},{3:F3} ({4:F2} x {5:F2} in)",
e.MinPoint.X, e.MinPoint.Y, e.MaxPoint.X, e.MaxPoint.Y,
e.MaxPoint.X-e.MinPoint.X, e.MaxPoint.Y-e.MinPoint.Y));
Log(String.Format(" inside title block (0.165-10.815 x 0.287-16.765): {0}",
e.MinPoint.X > 0.165 && e.MaxPoint.X < 10.815 && e.MinPoint.Y > 0.287 && e.MaxPoint.Y < 16.765));
Ed.Regen();
Result
Log
image: C:\Users\sanja\OneDrive\_SurveyDisco\260802 - 4082 Sweetbriar Ln, Forest Park, GA 30297, USA\260802-vicinity.png (119957 bytes) vicinity map attached [20C72] layer=BLOCK_CLOSURE extents 0.652,3.520 -> 2.952,5.820 (2.30 x 2.30 in) inside title block (0.165-10.815 x 0.287-16.765): True
Notes
What worked, what didn't, job-specific gotchas — flagged notes feed the recipes.
No notes yet.