← Inbox

C3D-0147 · READ-ONLY: vicinity map label position and enclosing block [VIC-POS-2] done

Reports the VICINITY MAP label in paper space with its extents and layer, any polyline, line or block reference enclosing it, and existing OLE frames for reference, so the vicinity image can be placed over the label inside the block boundary. No changes.

Script file
C3D-0147.cs
Target
active document · paper space
Author
claude
Approved
yes · reviewer
Timeout
240s

C# payload

// READ-ONLY. Where does the vicinity map go? Report the VICINITY MAP label in *Paper_Space and the
// geometry of the block/border it sits inside, so an image can be placed over it within the block
// boundary. Also dump an existing Ole2Frame for reference. Nothing is modified.
var bt = (BlockTable)Tx.GetObject(Db.BlockTableId, OpenMode.ForRead);
Log("drawing: " + Db.Filename);

var ps = (BlockTableRecord)Tx.GetObject(bt[BlockTableRecord.PaperSpace], OpenMode.ForRead);

Log("=== the VICINITY MAP label in *Paper_Space ===");
Extents3d? lblExt = null;
foreach (ObjectId id in ps) {
    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;
    lblExt = e;
    Log(String.Format("  [{0}] {1} layer={2}", o.Handle, o.GetType().Name, ent.Layer));
    Log(String.Format("     text \"{0}\"", s));
    Log(String.Format("     extents {0:F3},{1:F3} -> {2:F3},{3:F3}", e.MinPoint.X, e.MinPoint.Y, e.MaxPoint.X, e.MaxPoint.Y));
    if (mt != null) Log(String.Format("     location {0:F3},{1:F3}  height {2:F3}", mt.Location.X, mt.Location.Y, mt.TextHeight));
}

// what encloses it? report nearby closed polylines / lines in paper space
if (lblExt.HasValue) {
    var L = lblExt.Value;
    double cx = (L.MinPoint.X + L.MaxPoint.X)/2, cy = (L.MinPoint.Y + L.MaxPoint.Y)/2;
    Log("");
    Log(String.Format("=== geometry near the label (centre {0:F2},{1:F2}) ===", cx, cy));
    foreach (ObjectId id in ps) {
        Autodesk.AutoCAD.DatabaseServices.DBObject o;
        try { o = Tx.GetObject(id, OpenMode.ForRead); } catch { continue; }
        var ent = o as Autodesk.AutoCAD.DatabaseServices.Entity;
        if (ent == null) continue;
        if (!(o is Polyline || o is Line || o is BlockReference)) continue;
        Extents3d e;
        try { e = ent.GeometricExtents; } catch { continue; }
        double ecx=(e.MinPoint.X+e.MaxPoint.X)/2, ecy=(e.MinPoint.Y+e.MaxPoint.Y)/2;
        if (Math.Abs(ecx-cx) > 12 || Math.Abs(ecy-cy) > 12) continue;
        Log(String.Format("  [{0}] {1,-14} layer={2,-18} {3:F3},{4:F3} -> {5:F3},{6:F3}  ({7:F2} x {8:F2})",
            o.Handle, o.GetType().Name, ent.Layer, 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("");
Log("=== an existing Ole2Frame for reference ===");
foreach (ObjectId btrId in bt) {
    var btr = (BlockTableRecord)Tx.GetObject(btrId, OpenMode.ForRead);
    foreach (ObjectId id in btr) {
        var ol = Tx.GetObject(id, OpenMode.ForRead) as Ole2Frame;
        if (ol == null) continue;
        var e = ol.GeometricExtents;
        Log(String.Format("  [{0}] in {1} layer={2}  {3:F2} x {4:F2}",
            ol.Handle, btr.Name, ol.Layer, e.MaxPoint.X-e.MinPoint.X, e.MaxPoint.Y-e.MinPoint.Y));
    }
}

Result

Status
success
Drawing file
C:\Users\sanja\OneDrive\_SurveyDisco\260802 - 4082 Sweetbriar Ln, Forest Park, GA 30297, USA\260802 - 4082 Sweetbriar Ln.dwg
Message
Executed C3D-0147 (0 entities touched).
Entities
Duration
485 ms
Civil 3D
25.0.0.0

Log

drawing: C:\Users\sanja\OneDrive\_SurveyDisco\260802 - 4082 Sweetbriar Ln, Forest Park, GA 30297, USA\260802 - 4082 Sweetbriar Ln.dwg
=== the VICINITY MAP label in *Paper_Space ===
  [20955] DBText layer=BLOCK_CLOSURE
     text "VICINITY MAP (NOT TO SCALE)"
     extents 0.658,3.373 -> 1.999,3.460

=== geometry near the label (centre 1.33,3.42) ===
  [157DD] Line           layer=TB1                0.217,0.333 -> 10.783,0.333  (10.57 x 0.00)
  [157FB] Line           layer=BLOCK_NORTH_ARROW  10.424,13.503 -> 10.424,14.136  (0.00 x 0.63)
  [157FD] Line           layer=BLOCK_NORTH_ARROW  10.356,13.551 -> 10.424,14.136  (0.07 x 0.58)
  [157FE] Line           layer=BLOCK_NORTH_ARROW  10.409,13.539 -> 10.409,14.011  (0.00 x 0.47)
  [157FF] Line           layer=BLOCK_NORTH_ARROW  10.415,13.531 -> 10.415,14.063  (0.00 x 0.53)
  [15800] Line           layer=BLOCK_NORTH_ARROW  10.421,13.518 -> 10.421,14.115  (0.00 x 0.60)
  [15801] Line           layer=BLOCK_NORTH_ARROW  10.391,13.551 -> 10.391,13.854  (0.00 x 0.30)
  [15802] Line           layer=BLOCK_NORTH_ARROW  10.385,13.553 -> 10.385,13.802  (0.00 x 0.25)
  [15803] Line           layer=BLOCK_NORTH_ARROW  10.379,13.554 -> 10.379,13.750  (0.00 x 0.20)
  [15804] Line           layer=BLOCK_NORTH_ARROW  10.373,13.554 -> 10.373,13.698  (0.00 x 0.14)
  [15805] Line           layer=BLOCK_NORTH_ARROW  10.367,13.554 -> 10.367,13.646  (0.00 x 0.09)
  [15806] Line           layer=BLOCK_NORTH_ARROW  10.360,13.553 -> 10.360,13.593  (0.00 x 0.04)
  [15807] Line           layer=BLOCK_NORTH_ARROW  10.397,13.548 -> 10.397,13.906  (0.00 x 0.36)
  [15808] Line           layer=BLOCK_NORTH_ARROW  10.403,13.544 -> 10.403,13.959  (0.00 x 0.41)
  [15809] Line           layer=BLOCK_NORTH_ARROW  10.423,14.136 -> 10.424,14.387  (0.00 x 0.25)
  [1580B] Line           layer=BLOCK_NORTH_ARROW  10.318,15.160 -> 10.336,15.403  (0.02 x 0.24)
  [15836] Line           layer=BLOCK_NORTH_ARROW  10.367,15.164 -> 10.367,15.392  (0.00 x 0.23)
  [15837] Line           layer=BLOCK_NORTH_ARROW  10.360,15.164 -> 10.360,15.403  (0.00 x 0.24)
  [15838] Line           layer=BLOCK_NORTH_ARROW  10.354,15.164 -> 10.354,15.418  (0.00 x 0.25)
  [15839] Line           layer=BLOCK_NORTH_ARROW  10.348,15.163 -> 10.348,15.434  (0.00 x 0.27)
  [1583A] Line           layer=BLOCK_NORTH_ARROW  10.342,15.163 -> 10.342,15.450  (0.00 x 0.29)
  [1583B] Line           layer=BLOCK_NORTH_ARROW  10.336,15.163 -> 10.336,15.396  (0.00 x 0.23)
  [1584F] Line           layer=BLOCK_NORTH_ARROW  10.424,14.720 -> 10.424,14.933  (0.00 x 0.21)
  [15863] Line           layer=BLOCK_NORTH_ARROW  10.287,14.769 -> 10.313,15.098  (0.03 x 0.33)
  [15864] Line           layer=BLOCK_NORTH_ARROW  10.373,14.761 -> 10.373,15.102  (0.00 x 0.34)
  [15865] Line           layer=BLOCK_NORTH_ARROW  10.367,14.763 -> 10.367,15.102  (0.00 x 0.34)
  [15866] Line           layer=BLOCK_NORTH_ARROW  10.360,14.765 -> 10.360,15.102  (0.00 x 0.34)
  [15867] Line           layer=BLOCK_NORTH_ARROW  10.354,14.767 -> 10.354,15.101  (0.00 x 0.33)
  [15868] Line           layer=BLOCK_NORTH_ARROW  10.348,14.768 -> 10.348,15.101  (0.00 x 0.33)
  [15869] Line           layer=BLOCK_NORTH_ARROW  10.342,14.769 -> 10.342,15.100  (0.00 x 0.33)
  [1586A] Line           layer=BLOCK_NORTH_ARROW  10.336,14.770 -> 10.336,15.100  (0.00 x 0.33)
  [1586B] Line           layer=BLOCK_NORTH_ARROW  10.330,14.770 -> 10.330,15.100  (0.00 x 0.33)
  [1586C] Line           layer=BLOCK_NORTH_ARROW  10.324,14.770 -> 10.324,15.099  (0.00 x 0.33)
  [1586D] Line           layer=BLOCK_NORTH_ARROW  10.318,14.770 -> 10.318,15.099  (0.00 x 0.33)
  [1586E] Line           layer=BLOCK_NORTH_ARROW  10.312,14.770 -> 10.312,15.082  (0.00 x 0.31)
  [1586F] Line           layer=BLOCK_NORTH_ARROW  10.306,14.770 -> 10.306,15.004  (0.00 x 0.23)
  [15870] Line           layer=BLOCK_NORTH_ARROW  10.300,14.770 -> 10.300,14.926  (0.00 x 0.16)
  [15871] Line           layer=BLOCK_NORTH_ARROW  10.379,14.758 -> 10.379,15.102  (0.00 x 0.34)
  [15872] Line           layer=BLOCK_NORTH_ARROW  10.385,14.754 -> 10.385,15.102  (0.00 x 0.35)
  [15873] Line           layer=BLOCK_NORTH_ARROW  10.391,14.750 -> 10.391,15.102  (0.00 x 0.35)
  [15874] Line           layer=BLOCK_NORTH_ARROW  10.397,14.746 -> 10.397,15.102  (0.00 x 0.36)
  [15875] Line           layer=BLOCK_NORTH_ARROW  10.403,14.741 -> 10.403,15.003  (0.00 x 0.26)
  [15876] Line           layer=BLOCK_NORTH_ARROW  10.409,14.736 -> 10.409,14.994  (0.00 x 0.26)
  [15877] Line           layer=BLOCK_NORTH_ARROW  10.415,14.730 -> 10.415,14.984  (0.00 x 0.25)
  [15878] Line           layer=BLOCK_NORTH_ARROW  10.421,14.723 -> 10.421,14.975  (0.00 x 0.25)
  [1587A] Line           layer=BLOCK_NORTH_ARROW  10.424,14.518 -> 10.424,14.720  (0.00 x 0.20)
  [1587B] Line           layer=BLOCK_NORTH_ARROW  10.293,14.770 -> 10.293,14.848  (0.00 x 0.08)
  [1587C] Line           layer=BLOCK_NORTH_ARROW  10.287,14.769 -> 10.287,14.769  (0.00 x 0.00)
  [1589D] Line           layer=BLOCK_NORTH_ARROW  10.330,15.163 -> 10.330,15.317  (0.00 x 0.15)
  [1589E] Line           layer=BLOCK_NORTH_ARROW  10.324,15.163 -> 10.324,15.237  (0.00 x 0.07)
  [1589F] Line           layer=BLOCK_NORTH_ARROW  10.373,15.164 -> 10.373,15.382  (0.00 x 0.22)
  [158A0] Line           layer=BLOCK_NORTH_ARROW  10.379,15.165 -> 10.379,15.372  (0.00 x 0.21)
  [158A1] Line           layer=BLOCK_NORTH_ARROW  10.385,15.165 -> 10.385,15.362  (0.00 x 0.20)
  [158A2] Line           layer=BLOCK_NORTH_ARROW  10.391,15.165 -> 10.391,15.351  (0.00 x 0.19)
  [158A3] Line           layer=BLOCK_NORTH_ARROW  10.397,15.165 -> 10.397,15.341  (0.00 x 0.18)
  [158A4] Line           layer=BLOCK_NORTH_ARROW  10.403,15.166 -> 10.403,15.333  (0.00 x 0.17)
  [158A5] Line           layer=BLOCK_NORTH_ARROW  10.409,15.166 -> 10.409,15.325  (0.00 x 0.16)
  [158A6] Line           layer=BLOCK_NORTH_ARROW  10.415,15.166 -> 10.415,15.317  (0.00 x 0.15)
  [158A7] Line           layer=BLOCK_NORTH_ARROW  10.421,15.166 -> 10.421,15.309  (0.00 x 0.14)
  [158B9] Line           layer=BLOCK_NORTH_ARROW  10.424,14.982 -> 10.424,15.093  (0.00 x 0.11)
  [158BA] Line           layer=BLOCK_NORTH_ARROW  10.424,15.093 -> 10.424,15.102  (0.00 x 0.01)
  [158BB] Line           layer=BLOCK_NORTH_ARROW  10.424,14.933 -> 10.424,14.971  (0.00 x 0.04)
  [158BC] Line           layer=BLOCK_NORTH_ARROW  10.403,15.005 -> 10.403,15.102  (0.00 x 0.10)
  [158BD] Line           layer=BLOCK_NORTH_ARROW  10.409,14.998 -> 10.409,15.102  (0.00 x 0.10)
  [158BE] Line           layer=BLOCK_NORTH_ARROW  10.415,14.992 -> 10.415,15.102  (0.00 x 0.11)
  [158BF] Line           layer=BLOCK_NORTH_ARROW  10.421,14.985 -> 10.421,15.102  (0.00 x 0.12)
  [158CF] Line           layer=TB1                0.200,0.333 -> 0.217,16.705  (0.02 x 16.37)
  [1590E] Line           layer=BLOCK_STAMP        8.928,1.371 -> 8.973,1.417  (0.05 x 0.05)
  [1590F] Line           layer=BLOCK_STAMP        8.928,1.371 -> 8.973,1.417  (0.05 x 0.05)
  [15910] Line           layer=BLOCK_STAMP        8.951,1.361 -> 8.951,1.426  (0.00 x 0.06)
  [15911] Line           layer=BLOCK_STAMP        8.918,1.394 -> 8.983,1.394  (0.06 x 0.00)
  [15923] Line           layer=BLOCK_STAMP        10.179,1.383 -> 10.244,1.383  (0.06 x 0.00)
  [15924] Line           layer=BLOCK_STAMP        10.211,1.350 -> 10.211,1.415  (0.00 x 0.06)
  [15925] Line           layer=BLOCK_STAMP        10.189,1.360 -> 10.234,1.406  (0.05 x 0.05)
  [15926] Line           layer=BLOCK_STAMP        10.189,1.360 -> 10.234,1.406  (0.05 x 0.05)
  [15927] Polyline       layer=BLOCK_STAMP        8.727,1.094 -> 8.923,1.405  (0.20 x 0.31)
  [15928] Polyline       layer=BLOCK_STAMP        8.956,1.135 -> 9.094,1.388  (0.14 x 0.25)
  [15929] Polyline       layer=BLOCK_STAMP        9.146,1.127 -> 9.267,1.338  (0.12 x 0.21)
  [1592A] Polyline       layer=BLOCK_STAMP        9.301,1.030 -> 10.158,1.274  (0.86 x 0.24)
  [16615] Line           layer=BLOCK_CLOSURE      8.398,3.402 -> 8.398,3.449  (0.00 x 0.05)
  [16616] Line           layer=BLOCK_CLOSURE      8.406,3.402 -> 8.406,3.449  (0.00 x 0.05)
  [16617] Line           layer=BLOCK_CLOSURE      8.381,3.449 -> 8.406,3.449  (0.03 x 0.00)
  [16618] Polyline       layer=BLOCK_CLOSURE      8.438,3.434 -> 8.449,3.445  (0.01 x 0.01)
  [16619] Polyline       layer=BLOCK_CLOSURE      8.439,3.445 -> 8.448,3.603  (0.01 x 0.16)
  [1661B] Line           layer=BLOCK_CLOSURE      8.398,3.449 -> 8.421,3.449  (0.02 x 0.00)
  [1661F] Line           layer=BLOCK_CLOSURE      8.333,3.626 -> 8.382,3.626  (0.05 x 0.00)
  [16620] Line           layer=BLOCK_CLOSURE      8.382,3.611 -> 8.382,3.626  (0.00 x 0.02)
  [16621] Line           layer=BLOCK_CLOSURE      8.358,3.600 -> 8.382,3.611  (0.02 x 0.01)
  [16622] Line           layer=BLOCK_CLOSURE      8.416,3.600 -> 8.442,3.610  (0.03 x 0.01)
  [16623] Line           layer=BLOCK_CLOSURE      8.416,3.610 -> 8.417,3.626  (0.00 x 0.02)
  [16624] Line           layer=BLOCK_CLOSURE      8.333,3.622 -> 8.382,3.624  (0.05 x 0.00)
  [16625] Line           layer=BLOCK_CLOSURE      8.250,3.350 -> 8.505,3.618  (0.25 x 0.27)
  [16626] Line           layer=BLOCK_CLOSURE      8.233,3.332 -> 8.487,3.600  (0.25 x 0.27)
  [1664A] Polyline       layer=BLOCK_CLOSURE      8.237,3.432 -> 8.544,3.511  (0.31 x 0.08)
  [1664B] Polyline       layer=BLOCK_CLOSURE      8.152,3.271 -> 8.563,3.681  (0.41 x 0.41)
  [16FAE] Polyline       layer=SS-BOUNDARY CYAN   10.827,-0.000 -> 11.000,0.289  (0.17 x 0.29)
  [1FDBA] BlockReference layer=SS-BOUNDARY        7.590,13.371 -> 10.294,16.578  (2.70 x 3.21)
  [20355] BlockReference layer=BLOCK_TB2          0.165,0.287 -> 10.815,16.765  (10.65 x 16.48)

=== an existing Ole2Frame for reference ===
  [10C9C] in A$C2CD672AE layer=0  3018.63 x 728.83
  [10CA5] in A$C2CD672AE layer=www.cadblocksfree.com  25.93 x 9.47
  [10CA6] in A$C2CD672AE layer=www.cadblocksfree.com  1994.02 x 728.08
  [1E856] in *Paper_Space154 layer=SS-V-ROAD-CURB  3.35 x 2.35
  [1FEBB] in 11x17 COVER SHEET SS layer=0  7.14 x 6.70
  [1FEBC] in 11x17 COVER SHEET SS layer=0  7.50 x 5.80

Notes

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

No notes yet.