← Inbox

C3D-0641 · Storm labels: DI U1, U1->B1 pipe 6" HDPE, STM A1 slope [C3D-U1LBL] done

Worksheet items 5/7/8/9: add DI U1 label (RIM 726.80 / INV 725.32, pts 7778/7777), U1->B1 pipe label 6" HDPE + slope 725.32->724.90, STM A1 slope 6.76%. V-STORM-TEXT, SIMPLEX h=3.

Script file
C3D-0641.cs
Target
261004-C-Store As-Built Storm.dwg · model space
Author
claude
Approved
yes · auto-auth
Timeout
60s

C# payload

var ms=(BlockTableRecord)Tx.GetObject(SymbolUtilityServices.GetBlockModelSpaceId(Db),OpenMode.ForWrite);
var lt=(LayerTable)Tx.GetObject(Db.LayerTableId,OpenMode.ForRead);
var tst=(TextStyleTable)Tx.GetObject(Db.TextStyleTableId,OpenMode.ForRead);
ObjectId sid=tst["SIMPLEX"];
string P=((char)92).ToString()+"P";
Func<string,Autodesk.AutoCAD.DatabaseServices.DBObject> get=(hs)=>{ ObjectId id; Db.TryGetObjectId(new Handle(Convert.ToInt64(hs,16)),out id); return Tx.GetObject(id,OpenMode.ForRead); };
// idempotency
foreach(ObjectId id in ms){ var m=Tx.GetObject(id,OpenMode.ForRead) as MText; if(m!=null && m.Layer=="V-STORM-TEXT" && (m.Text.StartsWith("DI U1")||m.Text=="6.76%"||m.Text.Contains("6\" HDPE") && m.Text.Contains("18.46"))){ Log("SKIP - already labeled: "+m.Text); return; } }
Func<string,Point3d,AttachmentPoint,double,ObjectId> add=(txt,loc,att,rot)=>{ var m=new MText{Contents=txt,Location=loc,Attachment=att,TextHeight=3,TextStyleId=sid,Rotation=rot,Layer="V-STORM-TEXT"}; var oid=ms.AppendEntity(m); Tx.AddNewlyCreatedDBObject(m,true); return oid; };
var made=new List<ObjectId>();
// 7) DI U1 structure label (pts 7778 rim 726.80, 7777 inv 725.32)
made.Add(add("DI U1"+P+"RIM 726.80"+P+"INV 725.32"+P+"18\" CONC",new Point3d(2296598.18,1280019.33,0),AttachmentPoint.BottomRight,0));
// 8/9) U1 -> B1 pipe, 6" HDPE, 725.32 -> 724.90 (B1 note)
var u=(Line)get("4AF47");
double len=Math.Sqrt(Math.Pow(u.EndPoint.X-u.StartPoint.X,2)+Math.Pow(u.EndPoint.Y-u.StartPoint.Y,2));
double sl=(725.32-724.90)/len*100;
var d=new Vector2d(u.EndPoint.X-u.StartPoint.X,u.EndPoint.Y-u.StartPoint.Y).GetNormal(); var n=new Vector2d(-d.Y,d.X);
var mid=new Point2d((u.StartPoint.X+u.EndPoint.X)/2,(u.StartPoint.Y+u.EndPoint.Y)/2);
double ang=Math.Atan2(d.Y,d.X); if(ang<0) ang+=2*Math.PI;
made.Add(add(len.ToString("F2")+"' - 6\" HDPE",new Point3d(mid.X+3*n.X,mid.Y+3*n.Y,0),AttachmentPoint.MiddleCenter,ang));
made.Add(add(sl.ToString("F2")+"%",new Point3d(mid.X-3*n.X,mid.Y-3*n.Y,0),AttachmentPoint.MiddleCenter,ang));
// 5) STM A1 slope 722.87 -> 717.20, mirrored across the pipe from its length label
var a=(Line)get("30828"); var al=(MText)get("30832");
double alen=Math.Sqrt(Math.Pow(a.EndPoint.X-a.StartPoint.X,2)+Math.Pow(a.EndPoint.Y-a.StartPoint.Y,2));
double asl=(722.87-717.20)/alen*100;
var am=new Point2d((a.StartPoint.X+a.EndPoint.X)/2,(a.StartPoint.Y+a.EndPoint.Y)/2);
made.Add(add(asl.ToString("F2")+"%",new Point3d(2*am.X-al.Location.X,2*am.Y-al.Location.Y,0),AttachmentPoint.MiddleCenter,al.Rotation));
foreach(var id in made){ var m=(MText)Tx.GetObject(id,OpenMode.ForRead); Log("added h="+m.Handle+" "+m.Layer+" @"+m.Location.X.ToString("F2")+","+m.Location.Y.ToString("F2")+" rot="+(m.Rotation*180/Math.PI).ToString("F2")+" : "+m.Text.Replace(((char)13).ToString(),"").Replace(((char)10).ToString()," / ")+" (verified)"); }
Ed.Regen();

Result

Status
success
Drawing file
C:\Users\sanja\OneDrive\_SurveyDisco\261004 - 5030 E Lake Pkwy, Stockbridge, GA 30281, USA\261004-C-Store As-Built Storm.dwg
Message
Executed C3D-0641 (0 entities touched).
Entities
—
Duration
1373 ms
Civil 3D
25.0.0.0

Log

added h=4B041 V-STORM-TEXT @2296598.18,1280019.33 rot=0.00 : DI U1 / RIM 726.80 / INV 725.32 / 18" CONC (verified)
added h=4B042 V-STORM-TEXT @2296610.88,1280015.83 rot=339.03 : 18.46' - 6" HDPE (verified)
added h=4B043 V-STORM-TEXT @2296608.73,1280010.23 rot=339.03 : 2.28% (verified)
added h=4B044 V-STORM-TEXT @2296578.65,1280011.70 rot=276.27 : 6.76% (verified)

Notes

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

No notes yet.