← Inbox

C3D-0205 · READ-ONLY: does this drawing have a vicinity map frame done

Reports every raster with its source and whether the file exists, the image dictionary, any VICINITY MAP label with its extents, and the title block frame bounds, to decide whether to repoint an existing frame or attach the map fresh. No changes.

Script file
C3D-0205.cs
Target
active document · paper space
Author
claude
Approved
yes · auto-auth
Timeout
240s

C# payload


// READ-ONLY. Does THIS drawing already have a vicinity map frame, and where does the sheet want
// one? Reports rasters with their sources, the image dictionary, and any VICINITY MAP label with
// its position, so the map can either be repointed or attached fresh. Nothing is modified.
var bt = (BlockTable)Tx.GetObject(Db.BlockTableId, OpenMode.ForRead);
Log("drawing: " + Db.Filename);

Log("");
Log("=== rasters ===");
int n = 0;
foreach (ObjectId btrId in bt) {
    var btr = (BlockTableRecord)Tx.GetObject(btrId, OpenMode.ForRead);
    foreach (ObjectId id in btr) {
        var ri = Tx.GetObject(id, OpenMode.ForRead) as RasterImage;
        if (ri == null || ri.IsErased) continue;
        n++;
        var e = ri.GeometricExtents;
        string p = "(none)"; bool exists = false, loaded = false;
        try {
            var d = (RasterImageDef)Tx.GetObject(ri.ImageDefId, OpenMode.ForRead);
            p = d.SourceFileName; loaded = d.IsLoaded; exists = System.IO.File.Exists(p);
        } catch { }
        Log(String.Format("  [{0}] in {1}  layer={2}", ri.Handle, btr.Name, ri.Layer));
        Log(String.Format("      {0:F3},{1:F3} -> {2:F3},{3:F3}  ({4:F2} x {5:F2})  exists={6} loaded={7}",
            e.MinPoint.X, e.MinPoint.Y, e.MaxPoint.X, e.MaxPoint.Y,
            e.MaxPoint.X-e.MinPoint.X, e.MaxPoint.Y-e.MinPoint.Y, exists, loaded));
        Log("      " + p);
    }
}
Log("  rasters: " + n);

Log("");
Log("=== image dictionary ===");
try {
    var dictId = RasterImageDef.GetImageDictionary(Db);
    if (dictId.IsNull) Log("  (none)");
    else {
        var dict = (DBDictionary)Tx.GetObject(dictId, OpenMode.ForRead);
        foreach (DBDictionaryEntry de in dict) {
            var def = Tx.GetObject(de.Value, OpenMode.ForRead) as RasterImageDef;
            if (def == null) continue;
            Log("  \"" + de.Key + "\" loaded=" + def.IsLoaded + " exists=" + System.IO.File.Exists(def.SourceFileName));
            Log("      " + def.SourceFileName);
        }
    }
} catch (System.Exception ex) { Log("  " + ex.Message); }

Log("");
Log("=== VICINITY MAP labels (where the map belongs) ===");
foreach (ObjectId btrId in bt) {
    var btr = (BlockTableRecord)Tx.GetObject(btrId, OpenMode.ForRead);
    foreach (ObjectId id in btr) {
        Autodesk.AutoCAD.DatabaseServices.DBObject o;
        try { o = Tx.GetObject(id, OpenMode.ForRead); } catch { continue; }
        string s = null;
        var mt = o as MText;  if (mt != null) s = mt.Contents;
        var dt = o as DBText; if (dt != null) s = dt.TextString;
        if (s == null || s.ToUpper().IndexOf("VICINITY") < 0) continue;
        var ent = (Autodesk.AutoCAD.DatabaseServices.Entity)o;
        var e = ent.GeometricExtents;
        Log(String.Format("  [{0}] {1} in {2} layer={3}", o.Handle, o.GetType().Name, btr.Name, ent.Layer));
        Log("      \"" + s + "\"");
        Log(String.Format("      extents {0:F4},{1:F4} -> {2:F4},{3:F4}",
            e.MinPoint.X, e.MinPoint.Y, e.MaxPoint.X, e.MaxPoint.Y));
    }
}

Log("");
Log("=== title block reference (frame bounds) ===");
foreach (ObjectId btrId in bt) {
    var btr = (BlockTableRecord)Tx.GetObject(btrId, OpenMode.ForRead);
    if (!btr.IsLayout) continue;
    foreach (ObjectId id in btr) {
        var br = Tx.GetObject(id, OpenMode.ForRead) as BlockReference;
        if (br == null || br.Name.ToUpper().IndexOf("SS_BLOCK") < 0) continue;
        var e = br.GeometricExtents;
        Log(String.Format("  \"{0}\" [{1}] in {2}  {3:F4},{4:F4} -> {5:F4},{6:F4}",
            br.Name, br.Handle, btr.Name, e.MinPoint.X, e.MinPoint.Y, e.MaxPoint.X, e.MaxPoint.Y));
    }
}

Result

Status
success
Drawing file
C:\Users\sanja\OneDrive\_SurveyDisco\260613 - 5030 E Lake Pkwy, Stockbridge, GA 30281, USA\260612-Springdale Sanitary Sewer Extension As-Built 60.dwg
Message
Executed C3D-0205 (0 entities touched).
Entities
Duration
524 ms
Civil 3D
25.0.0.0

Log

drawing: C:\Users\sanja\OneDrive\_SurveyDisco\260613 - 5030 E Lake Pkwy, Stockbridge, GA 30281, USA\260612-Springdale Sanitary Sewer Extension As-Built 60.dwg

=== rasters ===
  [2EC1F] in *Paper_Space  layer=BLOCK_CLOSURE
      10.744,-4.236 -> 14.705,-0.275  (3.96 x 3.96)  exists=False loaded=False
      C:\Users\sanja\AppData\Local\Temp\vicinity_260612.png
  [1DAC] in _Wipeout_Circle  layer=0
      -0.499,-0.496 -> 0.499,0.500  (1.00 x 1.00)  exists=False loaded=False
      (none)
  [1240A] in _TagCircle  layer=0
      -0.125,-0.125 -> 0.125,0.125  (0.25 x 0.25)  exists=False loaded=False
      (none)
  [2823E] in As Built - DEV3896 East Lake Pkwy C-Store - Water & Sewer  layer=PDF2_GENERAL-TEXT
      1.387,3.328 -> 7.182,5.731  (5.79 x 2.40)  exists=True loaded=True
      C:\Users\sanja\OneDrive\_SurveyDisco\260613 - 5030 E Lake Pkwy, Stockbridge, GA 30281, USA\PDF Images\As Built - DEV3896 East Lake Pkwy C-Store - Water & Sewer087bf8df.png
  rasters: 4

=== image dictionary ===
  "As Built - DEV3896 East Lake Pkwy C-Store - Water & Sewer087bf8df" loaded=True exists=True
      C:\Users\sanja\OneDrive\_SurveyDisco\260613 - 5030 E Lake Pkwy, Stockbridge, GA 30281, USA\PDF Images\As Built - DEV3896 East Lake Pkwy C-Store - Water & Sewer087bf8df.png
  "VICINITY_260612" loaded=False exists=False
      C:\Users\sanja\AppData\Local\Temp\vicinity_260612.png

=== VICINITY MAP labels (where the map belongs) ===
  [2EC14] DBText in *Paper_Space layer=BLOCK_CLOSURE
      "VICINITY MAP (NOT TO SCALE)"
      extents 11.2223,-4.4006 -> 12.5635,-4.3137
  [1FF47] DBText in SS_BLOCK_11X17 (1) layer=BLOCK_TB2
      "VICINITY MAP (NOT TO SCALE)"
      extents -10.1607,3.0821 -> -8.3724,3.1979
  [1FFCA] DBText in SS_BLOCK_11X17 (2) layer=BLOCK_TB2
      "VICINITY MAP (NOT TO SCALE)"
      extents -10.1607,3.0821 -> -8.3724,3.1979
  [2007B] DBText in SS_BLOCK_11X17 (3) layer=BLOCK_TB2
      "VICINITY MAP (NOT TO SCALE)"
      extents -10.1607,3.0821 -> -8.3724,3.1979
  [2EBD2] DBText in A$C4402922d layer=BLOCK_CLOSURE
      "VICINITY MAP (NOT TO SCALE)"
      extents -1.0049,-0.0033 -> 0.3362,0.0836
  [2EBD8] DBText in A$Cb44c2f52 layer=BLOCK_CLOSURE
      "VICINITY MAP (NOT TO SCALE)"
      extents -1.0049,-0.0033 -> 0.3362,0.0836
  [2EBDE] DBText in A$C5f68f1ea layer=BLOCK_CLOSURE
      "VICINITY MAP (NOT TO SCALE)"
      extents -1.0049,-0.0033 -> 0.3362,0.0836
  [2EBE4] DBText in A$C3dab9042 layer=BLOCK_CLOSURE
      "VICINITY MAP (NOT TO SCALE)"
      extents -1.0049,-0.0033 -> 0.3362,0.0836
  [2EBEA] DBText in A$Cb5192841 layer=BLOCK_CLOSURE
      "VICINITY MAP (NOT TO SCALE)"
      extents -1.0049,-0.0033 -> 0.3362,0.0836
  [2EBF0] DBText in A$Ccb74734a layer=BLOCK_CLOSURE
      "VICINITY MAP (NOT TO SCALE)"
      extents -1.0049,-0.0033 -> 0.3362,0.0836
  [2EBF6] DBText in A$C11cb5e5a layer=BLOCK_CLOSURE
      "VICINITY MAP (NOT TO SCALE)"
      extents -1.0049,-0.0033 -> 0.3362,0.0836
  [2EBFC] DBText in A$C89efcd87 layer=BLOCK_CLOSURE
      "VICINITY MAP (NOT TO SCALE)"
      extents -1.0049,-0.0033 -> 0.3362,0.0836
  [2EC02] DBText in A$C5645242b layer=BLOCK_CLOSURE
      "VICINITY MAP (NOT TO SCALE)"
      extents -1.0049,-0.0033 -> 0.3362,0.0836
  [2EC08] DBText in A$Ceafd2981 layer=BLOCK_CLOSURE
      "VICINITY MAP (NOT TO SCALE)"
      extents -1.0049,-0.0033 -> 0.3362,0.0836
  [2EC0E] DBText in A$Cc7f9d2a5 layer=BLOCK_CLOSURE
      "VICINITY MAP (NOT TO SCALE)"
      extents 0.0054,-0.0190 -> 1.3466,0.0679

=== title block reference (frame bounds) ===
  "SS_BLOCK_11X17" [23273] in *Paper_Space  0.2681,0.2301 -> 21.7771,16.7073

Notes

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

No notes yet.