← Inbox

C3D-0416 · READ-ONLY: vicinity label positions, existing rasters, title-block frames [C3D-VICSTATE] done

Per layout: the VICINITY MAP label extents, any existing RasterImage (with source path), the SS_BLOCK frame extents, and whether the image dictionary / embed xrecord exist. Needed to place the vicinity map correctly and idempotently.

Script file
C3D-0416.cs
Target
812 Christmas Ave.dwg · paper space
Author
claude
Approved
yes · auto-auth
Timeout
120s

C# payload

// Current vicinity state: VICINITY label position per layout, any existing RasterImage, the
// title-block frame extents, and the image-definition dictionary.
Log("drawing: " + Db.Filename);
var dict=(DBDictionary)Tx.GetObject(Db.LayoutDictionaryId,OpenMode.ForRead);
foreach (DBDictionaryEntry de in dict){
    var lay=(Layout)Tx.GetObject(de.Value,OpenMode.ForRead);
    if(lay.LayoutName=="Model") continue;
    var btr=(BlockTableRecord)Tx.GetObject(lay.BlockTableRecordId,OpenMode.ForRead);
    Point3d lbl=Point3d.Origin; string lblH=""; double lx0=0,ly0=0,lx1=0,ly1=0; bool haveLbl=false;
    int raster=0; string tbName=""; double tx0=0,ty0=0,tx1=0,ty1=0; bool haveTb=false;
    foreach (ObjectId id in btr){
        var o=Tx.GetObject(id,OpenMode.ForRead);
        var mt=o as MText; var dt=o as DBText;
        string t=mt!=null?mt.Contents:(dt!=null?dt.TextString:"");
        if(t.ToUpper().Contains("VICINITY")){
            var e=(Autodesk.AutoCAD.DatabaseServices.Entity)o;
            try{ var ex=e.GeometricExtents; lx0=ex.MinPoint.X;ly0=ex.MinPoint.Y;lx1=ex.MaxPoint.X;ly1=ex.MaxPoint.Y; }catch{}
            lblH=e.Handle.ToString(); haveLbl=true;
        }
        if(o is RasterImage){ var ri=(RasterImage)o; raster++; string src=""; try{ var d2=(RasterImageDef)Tx.GetObject(ri.ImageDefId,OpenMode.ForRead); src=d2.SourceFileName; }catch{} Log("   RASTER ["+ri.Handle+"] on "+ri.Layer+" src=\""+src+"\""); }
        var br=o as BlockReference;
        if(br!=null){ var bd=(BlockTableRecord)Tx.GetObject(br.BlockTableRecord,OpenMode.ForRead); if(bd.Name.IndexOf("SS_BLOCK",StringComparison.OrdinalIgnoreCase)>=0){ try{ var ex=br.GeometricExtents; tx0=ex.MinPoint.X;ty0=ex.MinPoint.Y;tx1=ex.MaxPoint.X;ty1=ex.MaxPoint.Y;tbName=bd.Name;haveTb=true; }catch{} } }
    }
    Log(string.Format("LAYOUT \"{0}\"  rasterCount={1}", lay.LayoutName, raster));
    if(haveLbl) Log(string.Format("   VICINITY label [{0}] ({1:F3},{2:F3})-({3:F3},{4:F3})", lblH, lx0,ly0,lx1,ly1));
    else Log("   no VICINITY label");
    if(haveTb) Log(string.Format("   title block {0} frame ({1:F3},{2:F3})-({3:F3},{4:F3})", tbName, tx0,ty0,tx1,ty1));
}
// image dictionary
Log("");
var nod=(DBDictionary)Tx.GetObject(Db.NamedObjectsDictionaryId,OpenMode.ForRead);
Log("has ACAD_IMAGE_DICT: " + nod.Contains("ACAD_IMAGE_DICT"));
Log("has C3D_VICINITY_EMBED xrecord: " + nod.Contains("C3D_VICINITY_EMBED"));

Result

Status
success
Drawing file
C:\Users\sanja\OneDrive\_SurveyDisco\260903 - 812 Christmas Ave, Bethlehem, GA 30620, USA\812 Christmas Ave.dwg
Message
Executed C3D-0416 (0 entities touched).
Entities
Duration
568 ms
Civil 3D
25.0.0.0

Log

drawing: C:\Users\sanja\OneDrive\_SurveyDisco\260903 - 812 Christmas Ave, Bethlehem, GA 30620, USA\812 Christmas Ave.dwg
   RASTER [215E9] on BLOCK_CLOSURE src="C:\Users\sanja\OneDrive\_SurveyDisco\260714 - 285 Huckaby Rd, Brooks, GA 30205, USA\260714-vicinity.png"
LAYOUT "11X17"  rasterCount=1
   VICINITY label [20955] (0.658,3.373)-(1.999,3.460)
   title block SS_BLOCK_11X17 frame (0.165,0.287)-(10.815,16.765)
   RASTER [215E7] on BLOCK_CLOSURE src="C:\Users\sanja\OneDrive\_SurveyDisco\260714 - 285 Huckaby Rd, Brooks, GA 30205, USA\260714-vicinity.png"
LAYOUT "17X11"  rasterCount=1
   VICINITY label [20EC7] (2.682,8.011)-(4.023,8.098)
   title block SS_BLOCK_17X11 frame (0.330,0.330)-(16.670,10.670)
LAYOUT "HOUSEDIM"  rasterCount=0
   VICINITY label [1E807] (1.184,3.570)-(2.972,3.686)
LAYOUT "Layout1"  rasterCount=0
   no VICINITY label

has ACAD_IMAGE_DICT: True
has C3D_VICINITY_EMBED xrecord: True

Notes

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

No notes yet.