← Inbox

C3D-VICMAP · Vicinity map on 11X17 (Google Static Maps) done

Attach 260702-vicinity.png just above the VICINITY MAP label on layout 11X17 at (0.652, 3.467), 2.30in square, layer BLOCK_CLOSURE. Image fetched from Google Static Maps (key from C:/dev/.env.dev.local), zoom 14, marker on 358 St Johns Ave SW. Idempotent + verifies. NOT RUN - awaiting your approval.

Script file
C3D-VICMAP.cs
Target
active document · model space
Author
claude
Approved
no
Timeout
60s

C# payload

// Attach the Google vicinity map raster on layout 11X17, just above the "VICINITY MAP (NOT TO SCALE)"
// label (DBText handle 20955 @ (0.652,3.392), paper inches).
// Idempotent: bails if a raster of this name is already attached.
const string IMGNAME = "260702-vicinity";
string path = @"C:\Users\sanja\OneDrive\_SurveyDisco\260702 - 358 St Johns Ave SW, Atlanta, GA 30315, USA\260702-vicinity.png";
if (!System.IO.File.Exists(path)) { Log("image not found: " + path); return; }

// locate the 11X17 layout block
var lm = LayoutManager.Current;
ObjectId layBtrId = ObjectId.Null;
var bt = (BlockTable)Tx.GetObject(Db.BlockTableId, OpenMode.ForRead);
foreach (ObjectId btrId in bt) {
    var b = (BlockTableRecord)Tx.GetObject(btrId, OpenMode.ForRead);
    if (!b.IsLayout) continue;
    var lay = (Layout)Tx.GetObject(b.LayoutId, OpenMode.ForRead);
    if (lay.LayoutName == "11X17") { layBtrId = btrId; break; }
}
if (layBtrId.IsNull) { Log("layout 11X17 not found"); return; }

// image dictionary + definition
var dictId = RasterImageDef.GetImageDictionary(Db);
if (dictId.IsNull) dictId = RasterImageDef.CreateImageDictionary(Db);
var dict = (DBDictionary)Tx.GetObject(dictId, OpenMode.ForWrite);

// idempotency: already attached?
var lbtr = (BlockTableRecord)Tx.GetObject(layBtrId, OpenMode.ForRead);
foreach (ObjectId id in lbtr) {
    var ri = Tx.GetObject(id, OpenMode.ForRead) as RasterImage;
    if (ri != null && ri.Layer == "BLOCK_CLOSURE") { Log("A raster is already on BLOCK_CLOSURE in 11X17 — skipping (idempotent)."); return; }
}

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);
}

// place: square map, 2.30" wide, sitting just above the label at y=3.392
double w = 2.30, h = 2.30;
double x0 = 0.652, y0 = 3.392 + 0.075;   // label height 0.057 + a little clearance
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 lbtrW = (BlockTableRecord)Tx.GetObject(layBtrId, OpenMode.ForWrite);
lbtrW.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);
Log($"Vicinity map attached on 11X17 @({x0:F3},{y0:F3}) size {w:F2}x{h:F2}\" layer={chk.Layer} (verified).");

Result

Status
success
Drawing file
C:\Users\sanja\OneDrive\_SurveyDisco\260702 - 358 St Johns Ave SW, Atlanta, GA 30315, USA\260702 - 358 St Johns Ave SW.dwg
Message
Executed C3D-VICMAP (0 entities touched).
Entities
Duration
349 ms
Civil 3D
25.0.0.0

Log

Vicinity map attached on 11X17 @(0.652,3.467) size 2.30x2.30" layer=BLOCK_CLOSURE (verified).

Notes

What worked, what didn't, job-specific gotchas — flagged notes feed the recipes.

No notes yet.