← Inbox

C3D-TBREAD · Read title block attributes (read-only) done

Enumerate attributed blocks across layouts to see the title block tags before filling

Script file
C3D-TBREAD.cs
Target
active document · model space
Author
claude
Approved
yes · claude (session)
Timeout
60s

C# payload

// Read-only: enumerate block references with attributes across ALL layouts + model, so we can see
// the title block's attribute TAGS and current values before writing anything.
var bt = (BlockTable)Tx.GetObject(Db.BlockTableId, OpenMode.ForRead);
int nb = 0;
foreach (ObjectId btrId in bt) {
    var btr = (BlockTableRecord)Tx.GetObject(btrId, OpenMode.ForRead);
    if (btr.IsLayout) {
        var lay = (Layout)Tx.GetObject(btr.LayoutId, OpenMode.ForRead);
        foreach (ObjectId id in btr) {
            var o = Tx.GetObject(id, OpenMode.ForRead);
            if (o is BlockReference br) {
                var def = (BlockTableRecord)Tx.GetObject(br.DynamicBlockTableRecord, OpenMode.ForRead);
                if (br.AttributeCollection == null || br.AttributeCollection.Count == 0) continue;
                Log($"--- LAYOUT '{lay.LayoutName}' BLOCK '{def.Name}' handle={br.Handle} attrs={br.AttributeCollection.Count}");
                foreach (ObjectId aid in br.AttributeCollection) {
                    var ar = (AttributeReference)Tx.GetObject(aid, OpenMode.ForRead);
                    Log($"    TAG '{ar.Tag}' = \"{ar.TextString}\"");
                }
                nb++;
            }
        }
    }
}
Log($"BLOCKS WITH ATTRIBUTES: {nb}");

Result

Status
success
Drawing file
C:\Users\sanja\OneDrive\_SurveyDisco\260702 - 358 St Johns Ave SW, Atlanta, GA 30315, USA\260702 - 358 St Johns Ave SW.dwg
Message
Executed C3D-TBREAD (0 entities touched).
Entities
Duration
308 ms
Civil 3D
25.0.0.0

Log

--- LAYOUT '11X17' BLOCK 'SS_BLOCK_11X17' handle=20355 attrs=10
    TAG 'JOB_NO' = "JOB NO.: 251103"
    TAG 'SITE_ADDRESS' = "2850 Riderwood Dr, Decatur, GA 30033, USA"
    TAG 'REF_DB_PG' = "REF DB  Page "
    TAG 'LAND_LOT' = "LAND LOT: 147"
    TAG 'DISTRICT' = "DISTRICT: 18th"
    TAG 'COUNTY' = "COUNTY: Dekalb"
    TAG 'DATE' = "DATE: 11/11/25"
    TAG 'SUBDIVISION_NAME_LOT' = ""
    TAG 'PREP_FOR' = "ANGELA & LLOYD BARNETT"
    TAG 'SURVEY_TYPE' = "Survey"
BLOCKS WITH ATTRIBUTES: 1

Notes

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

No notes yet.