C3D-FINDFIRM · Find FIRM panel text on the sheet done
Read-only: locates any MText/DBText/attribute on the 22X17 C sheet mentioning FIRM, panel, flood or 13121, including inside block definitions.
C# payload
// READ-ONLY: find text on the 22X17 C sheet mentioning a FIRM panel / flood zone, so the wrong
// panel number can be corrected from the SurveyDisco record (13121C0338F, 09/18/2013, zone X).
// Searches MText, DBText and block attributes in paper space.
const string LAYOUT = "22X17 C";
var keys = new[] { "FIRM", "PANEL", "FLOOD", "13121", "COMMUNITY", "F.I.R.M", "MAP NO" };
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);
bool Hit(string s) { if (string.IsNullOrEmpty(s)) return false; var u = s.ToUpper();
foreach (var k in keys) if (u.Contains(k)) return true; return false; }
int n = 0;
foreach (ObjectId id in ps)
{
var e = Tx.GetObject(id, OpenMode.ForRead) as Autodesk.AutoCAD.DatabaseServices.Entity;
if (e == null) continue;
var mt = e as MText;
if (mt != null && Hit(mt.Contents))
{ Log($"MTEXT h={e.Handle} at ({mt.Location.X:F2},{mt.Location.Y:F2}) size={mt.TextHeight:F3} layer='{e.Layer}'"); Log($" >>> {mt.Contents.Replace("\n"," | ")}"); n++; continue; }
var dt = e as DBText;
if (dt != null && Hit(dt.TextString))
{ Log($"DBTEXT h={e.Handle} at ({dt.Position.X:F2},{dt.Position.Y:F2}) size={dt.Height:F3} layer='{e.Layer}'"); Log($" >>> {dt.TextString}"); n++; continue; }
var br = e as BlockReference;
if (br != null)
{
var d = (BlockTableRecord)Tx.GetObject(br.BlockTableRecord, OpenMode.ForRead);
foreach (ObjectId aid in br.AttributeCollection)
{
var ar = Tx.GetObject(aid, OpenMode.ForRead) as AttributeReference;
if (ar != null && (Hit(ar.TextString) || Hit(ar.Tag)))
{ Log($"ATTR block='{d.Name}' tag='{ar.Tag}' h={ar.Handle}"); Log($" >>> {ar.TextString}"); n++; }
}
// constant attributes / plain text inside the block definition
foreach (ObjectId bid in d)
{
var be = Tx.GetObject(bid, OpenMode.ForRead);
var bmt = be as MText; if (bmt != null && Hit(bmt.Contents)) { Log($"BLOCKDEF MTEXT in '{d.Name}' h={bmt.Handle}"); Log($" >>> {bmt.Contents.Replace("\n"," | ")}"); n++; }
var bdt = be as DBText; if (bdt != null && Hit(bdt.TextString)) { Log($"BLOCKDEF DBTEXT in '{d.Name}' h={bdt.Handle}"); Log($" >>> {bdt.TextString}"); n++; }
var bad = be as AttributeDefinition; if (bad != null && (Hit(bad.TextString)||Hit(bad.Tag))) { Log($"BLOCKDEF ATTDEF in '{d.Name}' tag='{bad.Tag}' h={bad.Handle}"); Log($" >>> {bad.TextString}"); n++; }
}
}
}
Log($"{n} match(es) on '{LAYOUT}'.");
Result
Log
MTEXT h=214F2 at (18.70,5.25) size=0.055 layer='BLOCK_NOTES_FLOOD' >>> FLOOD NOTE:\PTHIS PROPERTY IS NOT LOCATED WITHIN A SPECIAL FLOOD HAZARD AREA (SFHA) AS SHOWN ON F.I.R.M. COMMUNITY PANEL NO. 13135C0016G, EFFECTIVE FEBRUARY 4, 2013, AND LIES IN ZONE X. 1 match(es) on '22X17 C'.
Notes
What worked, what didn't, job-specific gotchas — flagged notes feed the recipes.
No notes yet.