C3D-0110 · Erase the duplicate fire hydrant 1A7D [DUP-FH-ERASE] done
Erases block reference 1A7D on FIRE_HYDRANT, which sits 0.09 feet from 194C - the same hydrant shot twice. Verifies the handle is a BlockReference on FIRE_HYDRANT before erasing and aborts otherwise. Confirms the remaining count.
C# payload
// Erase the duplicate fire hydrant: handle 1A7D at 2296377.44,1280101.12, which sits 0.09 ft from
// 194C at 2296377.46,1280101.20. Only 1A7D is touched.
//
// Verified before erasing: it must be a BlockReference on FIRE_HYDRANT at that position, otherwise
// ABORT. Nothing else is modified.
const string TARGET = "1A7D";
var ms = (BlockTableRecord)Tx.GetObject(SymbolUtilityServices.GetBlockModelSpaceId(Db), OpenMode.ForRead);
Log("drawing: " + Db.Filename);
ObjectId victim = ObjectId.Null;
foreach (ObjectId id in ms) {
Autodesk.AutoCAD.DatabaseServices.DBObject o;
try { o = Tx.GetObject(id, OpenMode.ForRead); } catch { continue; }
if (o.Handle.ToString() != TARGET) continue;
var br = o as BlockReference;
if (br == null) { Log("ABORT: " + TARGET + " is a " + o.GetType().Name + ", not a BlockReference"); return; }
if (br.Layer != "FIRE_HYDRANT") { Log("ABORT: " + TARGET + " is on " + br.Layer); return; }
Log(String.Format("target [{0}] {1} on {2} at {3:F2},{4:F2}", TARGET, br.Name, br.Layer, br.Position.X, br.Position.Y));
victim = id;
break;
}
if (victim.IsNull) { Log("ABORT: " + TARGET + " not found in model space"); return; }
var w = Tx.GetObject(victim, OpenMode.ForWrite);
w.Erase();
Log("erased " + TARGET);
int remaining = 0;
foreach (ObjectId id in ms) {
Autodesk.AutoCAD.DatabaseServices.DBObject o;
try { o = Tx.GetObject(id, OpenMode.ForRead); } catch { continue; }
if (o.IsErased) continue;
var ent = o as Autodesk.AutoCAD.DatabaseServices.Entity;
if (ent == null) continue;
try { if (ent.Layer == "FIRE_HYDRANT") remaining++; } catch { }
}
Log("FIRE_HYDRANT now holds " + remaining + " entities (verified)");
Ed.Regen();
Result
Log
drawing: C:\Users\sanja\OneDrive\_SurveyDisco\260613 - 5030 E Lake Pkwy, Stockbridge, GA 30281, USA\ACAD-260612 - CSTORE WATER ABS 30.dwg target [1A7D] *U80 on FIRE_HYDRANT at 2296377.44,1280101.12 erased 1A7D FIRE_HYDRANT now holds 3 entities (verified)
Notes
What worked, what didn't, job-specific gotchas — flagged notes feed the recipes.
No notes yet.