← Inbox

C3D-0618 · Storm as-built labels (pipes + structures) done

Like the sewer as-built: each storm pipe gets '<actual length>' - <plan size/material>' above it and its slope % (from the field inverts) below it, rotated to the pipe, on V-STORM-TEXT. Each structure note gets the structure name as its first line.

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

C# payload

string LAY="V-STORM-TEXT"; string PL="V-STORM-PIPE"; string P=((char)92).ToString()+"P"; double H=3.0;
var pts=new Dictionary<uint,CogoPoint>(); foreach(ObjectId id in CivilDoc.CogoPoints){ var p=(CogoPoint)Tx.GetObject(id,OpenMode.ForRead); pts[p.PointNumber]=p; }
var ms=(BlockTableRecord)Tx.GetObject(SymbolUtilityServices.GetBlockModelSpaceId(Db),OpenMode.ForWrite);
var notes=new List<MText>(); var pipesL=new List<Line>();
foreach(ObjectId id in ms){ var o=Tx.GetObject(id,OpenMode.ForRead); if(o is MText && ((MText)o).Layer==LAY) notes.Add((MText)o); if(o is Line && ((Line)o).Layer==PL) pipesL.Add((Line)o); }
var NM=new Dictionary<uint,string>();
NM[1109u]="DI A4";
NM[1108u]="DI A3";
NM[1107u]="DI A2";
NM[1139u]="DI-RISER A1";
NM[1110u]="DI B4";
NM[1082u]="DI B3";
NM[346u]="DI B2";
NM[1102u]="DI-RISER B1";
NM[1104u]="OCS C3";
// 1) structure notes get the structure name as the first line (like the sewer MH labels)
foreach(var kv in NM){
  if(!pts.ContainsKey(kv.Key)) continue; var p=pts[kv.Key]; var at=new Point3d(p.Easting+H,p.Northing+H,0);
  var m=notes.FirstOrDefault(x=>x.Location.DistanceTo(at)<0.5); if(m==null){ Log(kv.Value+": note not found"); continue; }
  if(m.Contents.StartsWith(kv.Value)){ Log(kv.Value+": note already named"); continue; }
  m.UpgradeOpen(); m.Contents=kv.Value+P+m.Contents; Log(kv.Value+" note -> "+m.Text.Replace("\n"," / ").Replace("\r",""));
}
// 2) pipe labels: length - size material above the pipe, slope below, rotated to the pipe
var PR=new List<object[]>();
PR.Add(new object[]{"STM A3",1109u,1108u,"18\" ALTyp2",725.48,724.35});
PR.Add(new object[]{"STM A2",1108u,1107u,"18\" ALTyp2",724.35,722.87});
PR.Add(new object[]{"STM A1",1107u,1139u,"18\" ALTyp2",722.87,double.NaN});
PR.Add(new object[]{"STM B3",1110u,1082u,"18\" RCP",724.11,722.45});
PR.Add(new object[]{"STM B2",1082u,346u,"18\" RCP",722.45,720.51});
PR.Add(new object[]{"STM B1",346u,1102u,"18\" RCP",720.51,722.37});
var existing=new HashSet<string>(notes.Select(x=>x.Text));
foreach(var r in PR){
  string nm=(string)r[0]; uint a=(uint)r[1], b=(uint)r[2]; string typ=(string)r[3]; double iu=(double)r[4], idn=(double)r[5];
  var pa=new Point3d(pts[a].Easting,pts[a].Northing,0); var pb=new Point3d(pts[b].Easting,pts[b].Northing,0);
  var ln=pipesL.FirstOrDefault(l=>l.StartPoint.DistanceTo(pa)<0.01&&l.EndPoint.DistanceTo(pb)<0.01);
  if(ln==null){ Log(nm+": pipe line not found - skipped"); continue; }
  double L=ln.Length; double ang=Math.Atan2(pb.Y-pa.Y,pb.X-pa.X); double rot=ang; if(rot>Math.PI/2||rot<=-Math.PI/2) rot+=Math.PI;
  var mid=new Point3d((pa.X+pb.X)/2,(pa.Y+pb.Y)/2,0); var nrm=new Vector3d(-Math.Sin(rot),Math.Cos(rot),0);
  string t1=L.ToString("F2")+"' - "+typ;
  string t2=double.IsNaN(idn)?null:((iu-idn)/L*100).ToString("F2")+"%";
  System.Action<string,Point3d> put=(txt,pos)=>{ var m=new MText(); m.SetDatabaseDefaults(); m.Layer=LAY; m.TextHeight=H; m.Attachment=AttachmentPoint.MiddleCenter; m.Location=pos; m.Rotation=rot; m.Contents=txt; ms.AppendEntity(m); Tx.AddNewlyCreatedDBObject(m,true); };
  if(existing.Contains(t1)){ Log(nm+": labels exist - skipped"); continue; }
  put(t1,mid+nrm*(H*1.0)); if(t2!=null) put(t2,mid-nrm*(H*1.0));
  Log(nm+" ("+NM[a]+" -> "+NM[b]+"): '"+t1+"'"+(t2!=null?"  '"+t2+"' (inv "+iu.ToString("F2")+" -> "+idn.ToString("F2")+")":"  no slope (pipe invert at "+NM[b]+" not measured)"));
}
Ed.Regen();

Result

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

Log

DI A4 note -> DI A4 / RIM 729.21 / INV 725.48 / 18" METAL
DI A3 note -> DI A3 / RIM 728.30 / INV 724.35 / 18" METAL
DI A2 note -> DI A2 / RIM 727.60 / INV 722.87 / 18" CONC
DI-RISER A1 note -> DI-RISER A1 / RIM 727.31 / INV 717.20 / 2' ROUND
DI B4 note -> DI B4 / RIM 727.51 / INV 724.11 / 18"
DI B3 note -> DI B3 / RIM 727.53 / INV 722.45 / 18" CONC
DI B2 note -> DI B2 / RIM 726.61 / INV 720.51 / 18" CONC
DI-RISER B1 note -> DI-RISER B1 / RIM 727.67 / INV 722.37 (18") / BOT 716.57 (24" RIDGED)
OCS C3 note -> OCS C3 / RIM 726.13 / INV 716.71 / 24" RIDGED
STM A3 (DI A4 -> DI A3): '33.34' - 18" ALTyp2'  '3.39%' (inv 725.48 -> 724.35)
STM A2 (DI A3 -> DI A2): '122.60' - 18" ALTyp2'  '1.21%' (inv 724.35 -> 722.87)
STM A1 (DI A2 -> DI-RISER A1): '83.87' - 18" ALTyp2'  no slope (pipe invert at DI-RISER A1 not measured)
STM B3 (DI B4 -> DI B3): '92.41' - 18" RCP'  '1.80%' (inv 724.11 -> 722.45)
STM B2 (DI B3 -> DI B2): '89.95' - 18" RCP'  '2.16%' (inv 722.45 -> 720.51)
STM B1 (DI B2 -> DI-RISER B1): '62.99' - 18" RCP'  '-2.95%' (inv 720.51 -> 722.37)

Notes

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

No notes yet.