← Inbox

C3DO-0755 · 261101: legend - add RBF and WM [C3D-LEGEND2] done

Add RBF REBAR FOUND and WM WATER METER to the legend text (2191D) after FF, and slide the symbol rows and sample lines below down by the measured line shift so they stay on their words.

Script file
C3DO-0755.cs
Target
261101 - 5491 Roswell Rd NE R2.dwg · model space
Author
claude
Approved
yes · auto-auth
Timeout
60s

C# payload

Func<string,ObjectId> oid=hs=>{ ObjectId id; Db.TryGetObjectId(new Handle(Convert.ToInt64(hs,16)),out id); return id; };
Func<MText,Dictionary<string,double>> lines=m=>{ var d=new Dictionary<string,double>(); var c=new DBObjectCollection(); m.Explode(c); foreach(Autodesk.AutoCAD.DatabaseServices.DBObject o in c){ var t=o as DBText; if(t!=null&&!d.ContainsKey(t.TextString.Trim())) d[t.TextString.Trim()]=t.Position.Y; o.Dispose(); } return d; };
var mid=oid("2191D"); if(mid.IsNull||mid.IsErased){ Log("STOP - legend text 2191D not found"); return; }
var mt=(MText)Tx.GetObject(mid,OpenMode.ForWrite);
var sp=(BlockTableRecord)Tx.GetObject(mt.OwnerId,OpenMode.ForRead);
var add=new[]{"RBF REBAR FOUND","WM WATER METER"};
var b=lines(mt); if(b.ContainsKey(add[0])){ Log("already there - nothing to do"); return; }
double yFF=b["FF FINISHED FLOOR"], oldDI=b["DROP INLET"], yLast=b.Values.Min();
var ext0=mt.GeometricExtents; double x0=4.90, x1=5.32;
var move=new List<Autodesk.AutoCAD.DatabaseServices.Entity>();
foreach(ObjectId id in sp){ if(id==mid) continue; var e=(Autodesk.AutoCAD.DatabaseServices.Entity)Tx.GetObject(id,OpenMode.ForRead); if(e is Viewport) continue;
 Extents3d x; try{ x=e.GeometricExtents; }catch{ continue; }
 if(x.MinPoint.X>=x0&&x.MaxPoint.X<=x1&&x.MaxPoint.Y<yFF&&x.MinPoint.Y>yLast-0.2) move.Add(e); }
string c0=mt.Contents; string key="FF FINISHED FLOOR"; int at=c0.IndexOf(key); if(at<0) throw new Exception("FF line not found");
at+=key.Length; string ins=""; foreach(var a in add) ins+=@"\P"+a;
mt.Contents=c0.Substring(0,at)+ins+c0.Substring(at);
var a2=lines(mt); double dy=a2["DROP INLET"]-oldDI;
foreach(var e in move){ e.UpgradeOpen(); e.TransformBy(Matrix3d.Displacement(new Vector3d(0,dy,0))); }
Log("added RBF REBAR FOUND + WM WATER METER after FF; moved "+move.Count+" symbol/sample pieces "+dy.ToString("F4")+" (verified: DROP INLET line "+oldDI.ToString("F4")+" -> "+a2["DROP INLET"].ToString("F4")+")");
Ed.Regen();

Result

Status
success
Drawing file
C:\Users\sanja\OneDrive\_SurveyDisco\261101 - Project\261101 - 5491 Roswell Rd NE R2.dwg
Message
Executed C3DO-0755 (0 entities touched).
Entities
—
Duration
496 ms
Civil 3D
25.0.0.0

Log

added RBF REBAR FOUND + WM WATER METER after FF; moved 0 symbol/sample pieces -0.3174 (verified: DROP INLET line 8.3119 -> 7.9945)

Notes

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

No notes yet.