← Inbox

C3D-TBDATE · Set title block DATE for 260619 running

Sets DATE to 07/22/26, the earliest field-photo date on the SurveyDisco record (no explicit survey-date field exists).

Script file
C3D-TBDATE.cs
Target
active document · paper space
Author
claude
Approved
yes · auto-auth
Timeout
60s

C# payload

// Set the title block DATE for job 260619 from the field-photo date (07/22/26 - earliest of the
// six site photos on the SurveyDisco record). The record has no explicit survey-date field.
// Reads back and verifies. Host owns Tx; host regens after commit.
const string BLK = "SS_BLOCK_22X17", LAYOUT = "22X17 C";
const string WANT = "DATE: 07/22/26";

var layDict = (DBDictionary)Tx.GetObject(Db.LayoutDictionaryId, OpenMode.ForRead);
var layout  = (Layout)Tx.GetObject(layDict.GetAt(LAYOUT), OpenMode.ForRead);
var ps      = (BlockTableRecord)Tx.GetObject(layout.BlockTableRecordId, OpenMode.ForRead);

foreach (ObjectId id in ps)
{
    var b0 = Tx.GetObject(id, OpenMode.ForRead) as BlockReference;
    if (b0 == null) continue;
    var d0 = (BlockTableRecord)Tx.GetObject(b0.BlockTableRecord, OpenMode.ForRead);
    if (d0.Name != BLK) continue;
    foreach (ObjectId aid in b0.AttributeCollection)
    {
        var ar = Tx.GetObject(aid, OpenMode.ForRead) as AttributeReference;
        if (ar == null || ar.Tag != "DATE") continue;
        string old = ar.TextString;
        if (old == WANT) { Log($"DATE already '{WANT}'."); return; }
        var w = (AttributeReference)Tx.GetObject(aid, OpenMode.ForWrite);
        w.TextString = WANT;
        string now = ((AttributeReference)Tx.GetObject(aid, OpenMode.ForRead)).TextString;
        Log($"DATE: '{old}' -> '{now}'{(now == WANT ? " (verified)" : " (MISMATCH)")}");
        return;
    }
}
Log("No DATE attribute found.");

Result

Status
success
Drawing file
C:\Users\sanja\OneDrive\_SurveyDisco\260619 - 3625 Stonewall Tell Rd, Atlanta, GA 30349, USA\260619 - 3625 Stonewall Tell Rd ROTATE.dwg
Message
Executed C3D-TBDATE (0 entities touched).
Entities
—
Duration
360 ms
Civil 3D
25.0.0.0

Log

DATE: 'DATE: 10/16/25' -> 'DATE: 07/22/26' (verified)

Notes

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

No notes yet.