← Inbox

C3D-0611 · Vault boxes to inserts (exact shape) done

The vault boxes are not true rectangles, so a scaled square missed by 0.08-0.14 ft. Make one block per vault (WATER_VAULT-1..3) holding that box's exact polyline, insert it on WATER_VAULT at the box centre, erase the polyline only when extents match. Remove the unused WATER_VAULT_BOX def.

Script file
C3D-0611.cs
Target
ACAD-260612-C-Store As-Built 60 H2O wPROFILE.dwg · model space
Author
claude
Approved
yes · auto-auth
Timeout
60s

C# payload

Func<string,ObjectId> H=(s)=>{ ObjectId i; Db.TryGetObjectId(new Handle(Convert.ToInt64(s,16)),out i); return i; };
var bt=(BlockTable)Tx.GetObject(Db.BlockTableId,OpenMode.ForWrite);
var ms=(BlockTableRecord)Tx.GetObject(SymbolUtilityServices.GetBlockModelSpaceId(Db),OpenMode.ForWrite);
if(bt.Has("WATER_VAULT_BOX")){ var ub=(BlockTableRecord)Tx.GetObject(bt["WATER_VAULT_BOX"],OpenMode.ForWrite); if(ub.GetBlockReferenceIds(true,false).Count==0){ ub.Erase(); Log("removed unused WATER_VAULT_BOX def"); } }
int k=0;
foreach(var hs in new[]{"1720","1722","17EC"}){
  k++; var id=H(hs); var pl=Tx.GetObject(id,OpenMode.ForRead) as Polyline;
  if(pl==null||pl.IsErased||!pl.Closed){ Log("vault "+hs+": skipped"); continue; }
  string BN="WATER_VAULT-"+k; if(bt.Has(BN)){ Log(BN+" exists - skipped"); continue; }
  var e1=pl.GeometricExtents; var c=new Point3d((e1.MinPoint.X+e1.MaxPoint.X)/2,(e1.MinPoint.Y+e1.MaxPoint.Y)/2,pl.Elevation);
  var b=new BlockTableRecord{Name=BN, Origin=Point3d.Origin}; var bid=bt.Add(b); Tx.AddNewlyCreatedDBObject(b,true);
  var cp=(Polyline)pl.Clone(); cp.Layer="0"; cp.TransformBy(Matrix3d.Displacement(Point3d.Origin-c));
  b.AppendEntity(cp); Tx.AddNewlyCreatedDBObject(cp,true);
  var br=new BlockReference(c,bid); br.SetDatabaseDefaults(); br.Layer="WATER_VAULT"; ms.AppendEntity(br); Tx.AddNewlyCreatedDBObject(br,true);
  var e2=br.GeometricExtents; double d=Math.Max(e1.MinPoint.DistanceTo(e2.MinPoint),e1.MaxPoint.DistanceTo(e2.MaxPoint));
  if(d<0.01){ pl.UpgradeOpen(); pl.Erase(); Log("vault "+hs+" -> "+BN+" insert h="+br.Handle+" on "+br.Layer+", exact shape, extents match ("+d.ToString("F4")+"), polyline erased (verified)"); }
  else { br.Erase(); Log("vault "+hs+": mismatch "+d.ToString("F4")+" - kept polyline"); }
}
Ed.Regen();

Result

Status
success
Drawing file
C:\Users\sanja\OneDrive\_SurveyDisco\260613 - 5030 E Lake Pkwy, Stockbridge, GA 30281, USA\REDLINE\ACAD-260612-C-Store As-Built 60 H2O wPROFILE.dwg
Message
Executed C3D-0611 (0 entities touched).
Entities
—
Duration
450 ms
Civil 3D
25.0.0.0

Log

removed unused WATER_VAULT_BOX def
vault 1720 -> WATER_VAULT-1 insert h=2FDC on WATER_VAULT, exact shape, extents match (0.0000), polyline erased (verified)
vault 1722 -> WATER_VAULT-2 insert h=2FE1 on WATER_VAULT, exact shape, extents match (0.0000), polyline erased (verified)
vault 17EC -> WATER_VAULT-3 insert h=2FE6 on WATER_VAULT, exact shape, extents match (0.0000), polyline erased (verified)

Notes

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

No notes yet.