C3D-VICOLE · Embed vicinity map (OLE) error
Embeds the vicinity map into the DWG as a Static OLE frame from a LOCAL temp PNG, so the image travels with the drawing and there is no OneDrive/raster path to break or hang on. 2.6in square above the VICINITY MAP label, with border.
C# payload
// Vicinity map, EMBEDDED (OLE) so it travels with the DWG - no external file reference.
// Previous attempt attached it as a RasterImage pointing at a OneDrive path: the def.Load()
// blocked while OneDrive hydrated the file, the ticket blew past its timeout, and the drawing
// was left depending on a path that breaks the moment the file moves or is unsynced.
// Source is a LOCAL temp PNG (Google Static Maps, roadmap z14, marker on site); it can be
// deleted afterwards because the bytes live inside the drawing.
// Placed above the "VICINITY MAP (NOT TO SCALE)" label at (8.48,0.51)-(9.83,0.60).
// Host owns Tx; host regens after commit.
const string LAYOUT = "22X17 C", LAYER = "BLOCK_CLOSURE";
const string IMG = @"C:\Users\sanja\AppData\Local\Temp\vicinity_260619.png";
const double SIZE = 2.60;
const double CX = 9.16, BOTTOM = 0.68;
if (!System.IO.File.Exists(IMG)) { Log("NOT FOUND: " + IMG); return; }
var layDict = (DBDictionary)Tx.GetObject(Db.LayoutDictionaryId, OpenMode.ForRead);
var layout = (Layout)Tx.GetObject(layDict.GetAt(LAYOUT), OpenMode.ForRead);
var ps = (BlockTableRecord)Tx.GetObject(layout.BlockTableRecordId, OpenMode.ForWrite);
var ole = new Ole2Frame();
ole.Layer = LAYER;
ole.SetDatabaseDefaults();
ole.WcsWidth = SIZE;
ole.WcsHeight = SIZE;
ole.Location = new Point3d(CX - SIZE/2.0, BOTTOM + SIZE, 0.0); // upper-left
ole.LinkPath = IMG;
ole.Type = OleType.Static; // Static = EMBEDDED bytes
ole.OutputQuality = OleOutputQuality.HighGraphics;
ps.AppendEntity(ole);
Tx.AddNewlyCreatedDBObject(ole, true);
var e = ole.GeometricExtents;
Log("Embedded vicinity map (OLE, Static/embedded) at (" +
e.MinPoint.X.ToString("F2") + "," + e.MinPoint.Y.ToString("F2") + ")-(" +
e.MaxPoint.X.ToString("F2") + "," + e.MaxPoint.Y.ToString("F2") + ") handle=" + ole.Handle);
var pl = new Polyline();
double x0 = CX - SIZE/2.0, y0 = BOTTOM;
pl.AddVertexAt(0, new Point2d(x0, y0), 0, 0, 0);
pl.AddVertexAt(1, new Point2d(x0 + SIZE, y0), 0, 0, 0);
pl.AddVertexAt(2, new Point2d(x0 + SIZE, y0 + SIZE), 0, 0, 0);
pl.AddVertexAt(3, new Point2d(x0, y0 + SIZE), 0, 0, 0);
pl.Closed = true;
pl.Layer = LAYER;
ps.AppendEntity(pl);
Tx.AddNewlyCreatedDBObject(pl, true);
Log("Border drawn. Image is embedded - the temp PNG can be deleted.");
Result
Notes
What worked, what didn't, job-specific gotchas — flagged notes feed the recipes.
No notes yet.