← Inbox

C3D-0276 · 260714 Huckaby: whole-drawing snapshot done

READ-ONLY. Full model-space read: layers x entity types with state, CogoPoints by description, all text, dimensions, blocks with attributes, Civil objects, layouts with viewports and paper size.

Script file
C3D-0276.cs
Target
260714 - 285 Huckaby Rd.dwg · model space
Author
claude
Approved
yes · auto-auth
Timeout
60s

C# payload


// READ-ONLY WHOLE-DRAWING SNAPSHOT.
//
// The earlier "snapshot" walked only polylines/lines/arcs outside layer 0 - written for a narrow
// linework-bulge diff, not a picture of the document. This reads EVERYTHING so any question about
// the drawing can be answered from one capture. Nothing is modified.
var lt  = (LayerTable)Tx.GetObject(Db.LayerTableId, OpenMode.ForRead);
var bt  = (BlockTable)Tx.GetObject(Db.BlockTableId, OpenMode.ForRead);
var ms  = (BlockTableRecord)Tx.GetObject(SymbolUtilityServices.GetBlockModelSpaceId(Db), OpenMode.ForRead);
Log("=== SNAPSHOT ===");
Log("drawing: " + Db.Filename);

// ---------------------------------------------------------------- layers x types
var perLayer = new Dictionary<string, Dictionary<string,int>>();
Action<string,string> bump = (lay, t) => {
    if (!perLayer.ContainsKey(lay)) perLayer[lay] = new Dictionary<string,int>();
    if (!perLayer[lay].ContainsKey(t)) perLayer[lay][t] = 0;
    perLayer[lay][t]++;
};
int model = 0, paper = 0, blockdef = 0;
foreach (ObjectId btrId in bt) {
    var btr = (BlockTableRecord)Tx.GetObject(btrId, OpenMode.ForRead);
    bool isModel = btr.Name.ToUpper() == "*MODEL_SPACE";
    foreach (ObjectId id in btr) {
        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 (isModel) model++; else if (btr.IsLayout) paper++; else blockdef++;
        string lay; try { lay = ent.Layer; } catch { continue; }
        bump(lay, o.GetType().Name);
    }
}
Log("");
Log("entities: model=" + model + "  paper=" + paper + "  blockdef=" + blockdef);

int nLayers = 0, nUsed = 0;
foreach (ObjectId lid in lt) { nLayers++; }
Log("");
Log("=== LAYERS IN USE ===");
var lnames = new List<string>(perLayer.Keys);
lnames.Sort();
foreach (var nm in lnames) {
    nUsed++;
    var parts = new List<string>();
    int tot = 0;
    foreach (var kv in perLayer[nm]) { parts.Add(kv.Key + ":" + kv.Value); tot += kv.Value; }
    string state = "";
    try {
        if (lt.Has(nm)) {
            var l = (LayerTableRecord)Tx.GetObject(lt[nm], OpenMode.ForRead);
            state = (l.IsOff ? " OFF" : "") + (l.IsFrozen ? " FROZEN" : "") + (l.IsLocked ? " LOCKED" : "");
        }
    } catch { }
    Log(String.Format("  {0,-34} n={1,-5}{2}  [{3}]", nm, tot, state, String.Join(" ", parts)));
}
Log("  layers total=" + nLayers + "  in use=" + nUsed);

// ---------------------------------------------------------------- points
var byDesc = new Dictionary<string,int>();
int npts = 0;
foreach (ObjectId id in ms) {
    var cp = Tx.GetObject(id, OpenMode.ForRead) as CogoPoint;
    if (cp == null) continue;
    npts++;
    string d = "";
    try { d = (cp.RawDescription ?? "").Trim().ToUpper(); } catch { }
    if (d.Length == 0) d = "<blank>";
    if (!byDesc.ContainsKey(d)) byDesc[d] = 0;
    byDesc[d]++;
}
Log("");
Log("=== COGO POINTS: " + npts + " ===");
var descs = new List<string>(byDesc.Keys); descs.Sort();
foreach (var d in descs) Log(String.Format("  {0,-42} {1}", d, byDesc[d]));

// ---------------------------------------------------------------- text
Log("");
Log("=== TEXT (model space) ===");
int ntext = 0;
foreach (ObjectId id in ms) {
    Autodesk.AutoCAD.DatabaseServices.DBObject o;
    try { o = Tx.GetObject(id, OpenMode.ForRead); } catch { continue; }
    string s = null; double h = 0;
    var mt = o as MText;  if (mt != null) { s = mt.Contents; h = mt.TextHeight; }
    var dt = o as DBText; if (dt != null) { s = dt.TextString; h = dt.Height; }
    if (s == null) continue;
    ntext++;
    var ent = (Autodesk.AutoCAD.DatabaseServices.Entity)o;
    Log(String.Format("  [{0}] {1,-18} h={2:F2}  \"{3}\"", o.Handle, ent.Layer, h,
        (s.Length > 70 ? s.Substring(0,70) + "..." : s).Replace("\n", " | ")));
}
Log("  model-space text: " + ntext);

// ---------------------------------------------------------------- dimensions
Log("");
Log("=== DIMENSIONS ===");
int ndim = 0;
foreach (ObjectId id in ms) {
    var dim = Tx.GetObject(id, OpenMode.ForRead) as Dimension;
    if (dim == null) continue;
    ndim++;
    double m = 0; try { m = dim.Measurement; } catch { }
    Log(String.Format("  [{0}] {1,-18} layer={2,-18} measure={3:F4}", dim.Handle, dim.GetType().Name, dim.Layer, m));
}
Log("  dimensions: " + ndim);

// ---------------------------------------------------------------- blocks + attributes
Log("");
Log("=== BLOCK REFERENCES WITH ATTRIBUTES ===");
foreach (ObjectId btrId in bt) {
    var btr = (BlockTableRecord)Tx.GetObject(btrId, OpenMode.ForRead);
    foreach (ObjectId id in btr) {
        var br = Tx.GetObject(id, OpenMode.ForRead) as BlockReference;
        if (br == null || br.AttributeCollection.Count == 0) continue;
        Log("  \"" + br.Name + "\" [" + br.Handle + "] in " + btr.Name);
        foreach (ObjectId aid in br.AttributeCollection) {
            var at = Tx.GetObject(aid, OpenMode.ForRead) as AttributeReference;
            if (at != null) Log(String.Format("      {0,-22} = \"{1}\"", at.Tag, at.TextString));
        }
    }
}

// ---------------------------------------------------------------- civil objects
Log("");
Log("=== CIVIL OBJECTS ===");
var civil = CivilApplication.ActiveDocument;
try {
    foreach (ObjectId sid in civil.GetSiteIds()) {
        var site = (Site)Tx.GetObject(sid, OpenMode.ForRead);
        var pids = site.GetParcelIds();
        if (pids.Count == 0) continue;
        Log("  SITE \"" + site.Name + "\"  parcels=" + pids.Count);
        foreach (ObjectId pid in pids) {
            var p = (Parcel)Tx.GetObject(pid, OpenMode.ForRead);
            Log(String.Format("     \"{0}\" [{1}] area={2:F2} layer={3}", p.Name, p.ObjectId.Handle, p.Area, p.Layer));
        }
    }
} catch (System.Exception ex) { Log("  sites: " + ex.Message); }

int nlbl = 0;
foreach (ObjectId id in ms) {
    var l = Tx.GetObject(id, OpenMode.ForRead) as Autodesk.Civil.DatabaseServices.Label;
    if (l != null) nlbl++;
}
Log("  civil labels=" + nlbl);

// ---------------------------------------------------------------- layouts
Log("");
Log("=== LAYOUTS ===");
var ldict = (DBDictionary)Tx.GetObject(Db.LayoutDictionaryId, OpenMode.ForRead);
foreach (DBDictionaryEntry de in ldict) {
    var lay = (Layout)Tx.GetObject(de.Value, OpenMode.ForRead);
    var lbtr = (BlockTableRecord)Tx.GetObject(lay.BlockTableRecordId, OpenMode.ForRead);
    int cnt = 0, vps = 0;
    foreach (ObjectId x in lbtr) {
        cnt++;
        if (Tx.GetObject(x, OpenMode.ForRead) is Viewport) vps++;
    }
    Log(String.Format("  \"{0}\" tab={1} entities={2} viewports={3} paper={4}",
        lay.LayoutName, lay.TabOrder, cnt, vps, lay.CanonicalMediaName));
}
Log("");
Log("=== SNAPSHOT END ===");

Result

Status
success
Drawing file
C:\Users\sanja\OneDrive\_SurveyDisco\260714 - 285 Huckaby Rd, Brooks, GA 30205, USA\260714 - 285 Huckaby Rd.dwg
Message
Executed C3D-0276 (0 entities touched).
Entities
Duration
457 ms
Civil 3D
25.0.0.0

Log

=== SNAPSHOT ===
drawing: C:\Users\sanja\OneDrive\_SurveyDisco\260714 - 285 Huckaby Rd, Brooks, GA 30205, USA\260714 - 285 Huckaby Rd.dwg

entities: model=216  paper=617  blockdef=4435

=== LAYERS IN USE ===
  0                                  n=936    [CogoPoint:150 Viewport:4 Line:612 Circle:31 Polyline:59 Leader:1 DBText:16 BlockReference:2 Arc:17 Wipeout:2 Hatch:25 Solid:2 Solid3d:3 Ole2Frame:3 MText:4 AttributeDefinition:5]
  A-BLDG                             n=3      [Line:3]
  BLOCK_CLOSURE                      n=64     [DBText:16 Line:24 Polyline:8 Arc:2 Solid:8 Polyline2d:4 MText:2]
  BLOCK_LEGEND                       n=40     [DBText:1 MText:2 BlockReference:5 Circle:2 Line:28 Solid:2]
  BLOCK_NORTH_ARROW                  n=404    [Line:360 Polyline2d:32 DBText:4 Arc:8]
  BLOCK_NOTES_FLOOD                  n=10     [MText:4 AttributeDefinition:6]
  BLOCK_STAMP                        n=68     [Arc:2 Circle:2 DBText:56 Line:8]
  BLOCK_TB2                          n=727    [BlockReference:2 Viewport:6 DBText:76 Line:578 MText:15 AttributeDefinition:50]
  C-0-GNRL-NOTE-INDX                 n=1      [MText:1]
  C-ANNO                             n=14     [MText:4 GeneralSegmentLabel:1 NoteLabel:8 Solid:1]
  C-ANNO-TABL-TTBL                   n=6      [Site:6]
  C-PROP-LINE                        n=1      [ParcelSegment:1]
  Defpoints                          n=40     [DBPoint:39 Polyline:1]
  FENCE-CHAIN                        n=1      [Line:1]
  G-NOTE                             n=114    [DBText:2 Line:106 Arc:2 Circle:2 AttributeDefinition:2]
  G-TTLB-HALF                        n=5      [DBText:3 AttributeDefinition:2]
  G-TTLB-LIGH                        n=5      [Line:3 Polyline:2]
  G-TTLB-THIN                        n=1      [Polyline:1]
  G-TTLB-TTF                         n=26     [AttributeDefinition:24 DBText:2]
  LABELS                             n=14    FROZEN  [DBText:12 DBPoint:2]
  LS-BOULDER                         n=12     [Hatch:3 Polyline:8 BlockReference:1]
  LS-EX. TREE                        n=150    [BlockReference:2 Circle:10 Hatch:2 Polyline:1 Arc:55 Line:80]
  PARCEL                             n=12     [Line:12]
  SPDETAIL                           n=1      [DBText:1]
  SPDIMENSION                        n=108    [Line:81 Solid:18 DBText:9]
  SPOVERVIEW                         n=1      [DBText:1]
  SPPAINT                            n=2093   [Line:2093]
  SPSHAPE_OUTLINE                    n=79     [Line:79]
  SS-0-FRAME                         n=3     FROZEN  [Line:2 CogoPoint:1]
  SS-BOUNDARY                        n=3      [BlockReference:2 MText:1]
  SS-BOUNDARY BLUE                   n=9      [Line:4 Arc:1 Polyline:4]
  SS-BOUNDARY CYAN                   n=4      [Line:2 Polyline:2]
  SS-BOUNDARY LAND LOT               n=68     [DBText:17 Line:25 Polyline:8 Arc:2 Solid:8 Polyline2d:4 MText:4]
  SS-BOUNDARY_PTS                    n=1      [MText:1]
  SS-BUFFER LANDSCAPE                n=2      [Site:2]
  SS-CL OF CREEK                     n=1      [Polyline:1]
  SS-FLOW WELL                       n=1      [Circle:1]
  SS-GAS                             n=1      [Line:1]
  SS-V-BLDG-OTLN                     n=51     [Polyline:4 Line:47]
  SS-V-BRKL-TOP                      n=2      [FeatureLine:1 Line:1]
  SS-V-ROAD-CNTR                     n=2      [Polyline:2]
  SS-V-ROAD-CURB                     n=86     [Site:1 Line:32 BlockReference:1 Circle:1 MText:13 AlignedDimension:12 Polyline:1 Ole2Frame:1 Solid:24]
  SS-V-ROAD-EPVM                     n=3      [Polyline:3]
  SS-V-TRANSMISSION CENTER LINE      n=4      [Line:4]
  SS-V-WALK                          n=1      [Polyline:1]
  SS-X-FENCE                         n=1      [Polyline:1]
  SS-X-FENCE WOOD                    n=19     [Polyline:3 Line:16]
  TB1                                n=18     [Line:18]
  TEXT                               n=1      [MText:1]
  TREES                              n=1      [DBText:1]
  V-CTRL-HCPT                        n=2      [BlockReference:2]
  V-NODE-STRM                        n=4      [BlockReference:4]
  V-NODE-WATR                        n=5      [BlockReference:4 Line:1]
  V-STRC-WALL                        n=8      [Polyline:4 Line:4]
  www.cadblocksfree.com              n=23     [Polyline:1 Ole2Frame:2 Line:15 Arc:3 BlockReference:2]
  X-DRIV-CONC                        n=5      [Polyline:3 Hatch:2]
  X-PROP-CRNR                        n=2      [Circle:2]
  X-STRM-STRC                        n=1      [Polyline:1]
  layers total=322  in use=58

=== COGO POINTS: 151 ===
  4INPOST OFF                                1
  A/C                                        1
  CL                                         10
  CLEAN OUT                                  1
  CON COR                                    3
  DECK COR                                   1
  DECK COR STEP                              1
  DWY                                        36
  DWY EP                                     2
  EP                                         5
  FC                                         2
  FL                                         3
  GAS                                        2
  HC                                         6
  HC  DECK COR                               1
  HL                                         4
  IPF                                        2
  IPF 4" POST                                1
  OTP                                        1
  PORCH COR                                  2
  PP                                         1
  STEP                                       2
  SW                                         31
  SW STEP                                    2
  TML                                        11
  WALL                                       14
  WELL HOUSE                                 4
  WV                                         1

=== TEXT (model space) ===
  [20B78] LABELS             h=73.45  "POB"
  [20B7A] LABELS             h=73.45  "P1"
  [20B7C] LABELS             h=73.45  "P2"
  [20B7E] LABELS             h=73.45  "P3"
  [20B80] LABELS             h=73.45  "P4"
  [20B82] LABELS             h=73.45  "P5"
  model-space text: 6

=== DIMENSIONS ===
  dimensions: 0

=== BLOCK REFERENCES WITH ATTRIBUTES ===
  "SS_BLOCK_17X11" [20E5D] in *Paper_Space
      JOB_NO                 = "JOB NO.: 260714"
      SITE_ADDRESS           = "285 Huckaby Rd, Brooks, GA 30205, USA"
      REF_DB_PG              = "REF DB 5857 Page 692"
      LAND_LOT               = "LAND LOT: 124"
      DISTRICT               = "DISTRICT: 4th"
      COUNTY                 = "COUNTY: Fayette"
      DATE                   = "DATE: 08/13/26"
      SUBDIVISION_NAME_LOT   = ""
      PREP_FOR               = "JOY EWING"
      SURVEY_TYPE            = " Boundary Survey"
      FIRM_PANEL             = "13113C0155E,"
      FIRM_DATE              = "EFFECTIVE SEPTEMBER 26, 2008,"
      FLOOD_ZONE             = "AND LIES IN ZONE X."
  "SS_BLOCK_11X17" [20B53] in *Paper_Space178
      JOB_NO                 = "JOB NO.: 260714"
      SITE_ADDRESS           = "285 Huckaby Rd, Brooks, GA 30205, USA"
      REF_DB_PG              = "REF DB 5857 Page 692"
      LAND_LOT               = "LAND LOT: 124"
      DISTRICT               = "DISTRICT: 4th"
      COUNTY                 = "COUNTY: Fayette"
      DATE                   = "DATE: 08/13/26"
      SUBDIVISION_NAME_LOT   = ""
      PREP_FOR               = "JOY EWING"
      SURVEY_TYPE            = "Boundary Survey"
      FIRM_PANEL             = "13113C0155E,"
      FIRM_DATE              = "EFFECTIVE SEPTEMBER 26, 2008,"
      FLOOD_ZONE             = "AND LIES IN ZONE X."

=== CIVIL OBJECTS ===
  civil labels=0

=== LAYOUTS ===
  "11X17" tab=1 entities=141 viewports=2 paper=ANSI_full_bleed_B_(11.00_x_17.00_Inches)
  "17X11" tab=3 entities=138 viewports=2 paper=ANSI_full_bleed_B_(17.00_x_11.00_Inches)
  "HOUSEDIM" tab=2 entities=338 viewports=2 paper=ANSI_full_bleed_B_(11.00_x_17.00_Inches)
  "Layout1" tab=4 entities=0 viewports=0 paper=
  "Model" tab=0 entities=216 viewports=0 paper=ANSI_A_(8.50_x_11.00_Inches)

=== SNAPSHOT END ===

Notes

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

No notes yet.