← Inbox

C3D-FLOODFIX · Correct FIRM panel on flood note error

Replaces panel 13135C0016G / February 4, 2013 with 13121C0338F / September 18, 2013 from the SurveyDisco record for job 260619 (Fulton County). Zone X unchanged. Reads back and verifies.

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

C# payload

// Correct the flood note on 22X17 C: the FIRM panel/date were from another county.
// SurveyDisco record for job 260619 (Fulton County): firmPanel 13121C0338F,
// firmPanelDate 09/18/2013, floodZone X. Sheet had 13135C0016G / February 4, 2013 (Gwinnett).
// Targets the exact MText by handle-independent content match; reads back and verifies.
// Host owns Tx; host regens after commit.
const string LAYOUT = "22X17 C";
const string OLD_PANEL = "13135C0016G", NEW_PANEL = "13121C0338F";
const string OLD_DATE  = "FEBRUARY 4, 2013",  NEW_DATE  = "SEPTEMBER 18, 2013";

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);

int fixedN = 0;
foreach (ObjectId id in ps)
{
    var mt = Tx.GetObject(id, OpenMode.ForRead) as MText;
    if (mt == null) continue;
    var c = mt.Contents;
    if (c == null || (!c.Contains(OLD_PANEL) && !c.ToUpper().Contains(OLD_DATE))) continue;

    string updated = c.Replace(OLD_PANEL, NEW_PANEL);
    // date appears in mixed case on the sheet - replace case-insensitively
    int i = updated.ToUpper().IndexOf(OLD_DATE);
    if (i >= 0) updated = updated.Substring(0, i) + NEW_DATE + updated.Substring(i + OLD_DATE.Length);

    if (updated == c) { Log("  no change needed"); continue; }

    var w = (MText)Tx.GetObject(id, OpenMode.ForWrite);
    w.Contents = updated;
    string now = ((MText)Tx.GetObject(id, OpenMode.ForRead)).Contents;
    bool ok = now.Contains(NEW_PANEL) && now.Contains(NEW_DATE) && !now.Contains(OLD_PANEL);
    Log($"MText {mt.Handle} on '{mt.Layer}':");
    Log($"  OLD: {c.Replace("
"," | ")}");
    Log($"  NEW: {now.Replace("
"," | ")}");
    Log($"  {(ok ? "(verified)" : "(MISMATCH)")}");
    fixedN++;
}
Log($"Corrected {fixedN} flood note(s) to panel {NEW_PANEL}, {NEW_DATE}, Zone X (Fulton County).");

Result

Status
error
Drawing file
C:\Users\sanja\OneDrive\_SurveyDisco\260619 - 3625 Stonewall Tell Rd, Atlanta, GA 30349, USA\260619 - 3625 Stonewall Tell Rd ROTATE.dwg
Message
Compile error: (34,30): error CS8967: Newlines are not allowed inside a non-verbatim interpolated string; (34,19): error CS1073: Unexpected token ';'; (34,29): error CS1010: Newline in constant; (34,30): error CS1003: Syntax error, ',' expected; (36,9): error CS1010: Newline in constant; (36,32): error CS8967: Newlines are not allowed inside a non-verbatim interpolated string; (42,1): error CS1026: ) expected; (42,1): error CS1513: } expected
Entities
Duration
22 ms
Civil 3D
25.0.0.0

Notes

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

No notes yet.