← Inbox

C3D-0006 · Clear REF_DB_PG + SUBDIVISION on 22X17 [TB-CLEAR] done

Clears REF_DB_PG and SUBDIVISION_NAME_LOT on the 22X17 title block - both still carried stale job 260104 values and the 260612 record has neither. Cleared rather than guessed.

Script file
C3D-0006.cs
Target
260612 · paper space
Author
claude
Approved
yes · reviewer
Timeout
180s

C# payload

// Clear REF_DB_PG and SUBDIVISION_NAME_LOT on the 22X17 title block.
// Both still carry stale values from job 260104 (REF DB 13594 Page 389, and the placeholder
// "SUBDIVISION_NAME LOT ##"). The SurveyDisco record for 260612 has no deed book/page and no
// subdivision, so per the user these are CLEARED rather than filled with a guess:
// "ref and subd should be cleared if not available or specified by me".
// 22X17 only. Reads back after writing. Host owns Tx; host regens after commit.
const string LAYOUT = "22X17";
var clear = new string[] { "REF_DB_PG", "SUBDIVISION_NAME_LOT" };

var layDict = (DBDictionary)Tx.GetObject(Db.LayoutDictionaryId, OpenMode.ForRead);
if (!layDict.Contains(LAYOUT)) { Log("layout '" + LAYOUT + "' not found"); return; }
var layout = (Layout)Tx.GetObject(layDict.GetAt(LAYOUT), OpenMode.ForRead);
var ps = (BlockTableRecord)Tx.GetObject(layout.BlockTableRecordId, OpenMode.ForRead);

int cleared = 0;
foreach (ObjectId id in ps)
{
    var br = Tx.GetObject(id, OpenMode.ForRead) as BlockReference;
    if (br == null || br.AttributeCollection.Count == 0) continue;
    foreach (ObjectId aid in br.AttributeCollection)
    {
        var ar = Tx.GetObject(aid, OpenMode.ForRead) as AttributeReference;
        if (ar == null) continue;
        bool hit = false;
        foreach (var t in clear) if (t == ar.Tag) { hit = true; break; }
        if (!hit) continue;
        string old = ar.TextString;
        if (old == "") { Log("  " + ar.Tag + " already empty"); continue; }
        var w = (AttributeReference)Tx.GetObject(aid, OpenMode.ForWrite);
        w.TextString = "";
        string now = ((AttributeReference)Tx.GetObject(aid, OpenMode.ForRead)).TextString;
        Log("  " + ar.Tag.PadRight(22) + " '" + old + "'  ->  ''" + (now == "" ? "  (verified)" : "  (MISMATCH)"));
        cleared++;
    }
}
Log("cleared " + cleared + " attribute(s) on '" + LAYOUT + "'");

Result

Status
success
Drawing file
C:\Users\sanja\OneDrive\_SurveyDisco\260613 - 5030 E Lake Pkwy, Stockbridge, GA 30281, USA\260612 - CSTORE WATER ABS BOUNDARY.dwg
Message
Executed C3D-0006 (0 entities touched).
Entities
Duration
1568 ms
Civil 3D
25.0.0.0

Log

  REF_DB_PG              'REF DB 13594 Page 389'  ->  ''  (verified)
  SUBDIVISION_NAME_LOT   'SUBDIVISION_NAME LOT ##'  ->  ''  (verified)
cleared 2 attribute(s) on '22X17'

Notes

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

No notes yet.