← Inbox

C3D-WHEREIS · Find location clues in GUS.dwg (read-only) error

Dump all text, coordinate system, extents and point descriptions to identify the site address

Script file
C3D-WHEREIS.cs
Target
active document · model space
Author
claude
Approved
yes · claude (read-only inspection)
Timeout
60s

C# payload

// Read-only: find any clue about WHERE this drawing is. Dumps all text (model + every layout +
// block attributes), the coordinate extents, units, and any Civil 3D coordinate-system assignment.
var bt = (BlockTable)Tx.GetObject(Db.BlockTableId, OpenMode.ForRead);

Log($"UNITS: INSUNITS={Db.Insunits}");
try {
    var cd = CivilDoc;
    var zone = cd.Settings.DrawingSettings.UnitZoneSettings;
    Log($"COORD SYSTEM: '{zone.CoordinateSystemCode}'  desc='{zone.CoordinateSystemName}'");
} catch (System.Exception ex) { Log("coord system read failed: " + ex.Message); }

// extents tell us the coordinate space (state plane vs assumed/local)
double minx=double.MaxValue,miny=double.MaxValue,maxx=double.MinValue,maxy=double.MinValue;
int ents=0;
var ms = (BlockTableRecord)Tx.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForRead);
foreach (ObjectId id in ms) {
    var e = Tx.GetObject(id, OpenMode.ForRead) as Autodesk.AutoCAD.DatabaseServices.Entity;
    if (e == null) continue;
    ents++;
    try { var ex = e.GeometricExtents;
        if (ex.MinPoint.X<minx) minx=ex.MinPoint.X; if (ex.MinPoint.Y<miny) miny=ex.MinPoint.Y;
        if (ex.MaxPoint.X>maxx) maxx=ex.MaxPoint.X; if (ex.MaxPoint.Y>maxy) maxy=ex.MaxPoint.Y;
    } catch { }
}
Log($"MODEL: {ents} entities, extents ({minx:F2},{miny:F2}) - ({maxx:F2},{maxy:F2})");

// all text across model + layouts + block attributes
Log("--- TEXT (model + layouts + attributes) ---");
int shown = 0;
foreach (ObjectId btrId in bt) {
    var btr = (BlockTableRecord)Tx.GetObject(btrId, OpenMode.ForRead);
    string where = btr.Name;
    if (btr.IsLayout) { var lay = (Layout)Tx.GetObject(btr.LayoutId, OpenMode.ForRead); where = "LAYOUT:" + lay.LayoutName; }
    foreach (ObjectId id in btr) {
        var o = Tx.GetObject(id, OpenMode.ForRead);
        string s = null;
        if (o is MText mt) s = (mt.Contents ?? "").Replace("\\P", " / ");
        else if (o is DBText t) s = t.TextString;
        else if (o is BlockReference br && br.AttributeCollection != null) {
            foreach (ObjectId aid in br.AttributeCollection) {
                var ar = (AttributeReference)Tx.GetObject(aid, OpenMode.ForRead);
                var v = (ar.TextString ?? "").Trim();
                if (v.Length > 1) { Log($"  [{where}] ATTR {ar.Tag} = \"{v}\""); shown++; }
            }
            continue;
        }
        if (string.IsNullOrWhiteSpace(s) || s.Trim().Length < 3) continue;
        if (shown++ > 300) continue;
        Log($"  [{where}] \"{s.Trim()}\"");
    }
}
Log($"text items: {shown}");

// COGO points often carry the site in their descriptions
try {
    int n = 0;
    foreach (ObjectId id in CivilDoc.CogoPoints) {
        var cp = (Autodesk.Civil.DatabaseServices.CogoPoint)Tx.GetObject(id, OpenMode.ForRead);
        if (n++ < 12) Log($"  PT #{cp.PointNumber} '{cp.RawDescription}' E={cp.Easting:F2} N={cp.Northing:F2} Z={cp.Elevation:F2}");
    }
    Log($"cogo points: {n}");
} catch { Log("no cogo points"); }

Result

Status
error
Drawing file
C:\Users\sanja\Downloads\GUS.dwg
Message
Compile error: (9,68): error CS1061: 'SettingsUnitZone' does not contain a definition for 'CoordinateSystemName' and no accessible extension method 'CoordinateSystemName' accepting a first argument of type 'SettingsUnitZone' could be found (are you missing a using directive or an assembly reference?)
Entities
Duration
306 ms
Civil 3D
25.0.0.0

Notes

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

No notes yet.