← Inbox

C3DO-0829 · 261103 linework: white edge line (SS-V-ROAD-STRIPE) [C3D-LW1103-STRIPE] done

Draws the white edge line from the 261103 field points as regular Polylines on SS-V-ROAD-STRIPE: WSR S white line 120-125-156-157. Skips if that layer already has linework in the 261103 area.

Script file
C3DO-0829.cs
Target
261103 - 0 WALT STEPHENS RD.dwg · model space
Author
claude
Approved
yes · auto-auth
Timeout
60s

C# payload

string F(double v)=>v.ToString("0.###");
ObjectId H(string h)=>Db.GetObjectId(false,new Handle(Convert.ToInt64(h,16)),0);
ObjectId Lyr(string name,short c){ var lt=(LayerTable)Tx.GetObject(Db.LayerTableId,OpenMode.ForRead); if(lt.Has(name)) return lt[name]; lt.UpgradeOpen(); var r=new LayerTableRecord{Name=name,Color=Autodesk.AutoCAD.Colors.Color.FromColorIndex(Autodesk.AutoCAD.Colors.ColorMethod.ByAci,c)}; var id=lt.Add(r); Tx.AddNewlyCreatedDBObject(r,true); Log("layer created "+name); return id; }
ObjectId Put(BlockTableRecord btr, Autodesk.AutoCAD.DatabaseServices.Entity e, string layer){ e.SetDatabaseDefaults(Db); e.Layer=layer; var id=btr.AppendEntity(e); Tx.AddNewlyCreatedDBObject(e,true); return id; }
var LM=LayoutManager.Current;
BlockTableRecord PS(string name){ var l=(Layout)Tx.GetObject(LM.GetLayoutId(name),OpenMode.ForRead); return (BlockTableRecord)Tx.GetObject(l.BlockTableRecordId,OpenMode.ForWrite); }
var BT=(BlockTable)Tx.GetObject(Db.BlockTableId,OpenMode.ForRead);
var MS=(BlockTableRecord)Tx.GetObject(BT[BlockTableRecord.ModelSpace],OpenMode.ForWrite);
bool HasText(BlockTableRecord btr,string contains){ foreach(ObjectId id in btr){ var o=Tx.GetObject(id,OpenMode.ForRead); if(o is MText m && m.Contents.Contains(contains)) return true; if(o is DBText t && t.TextString.Contains(contains)) return true; } return false; }

// 261103 linework from field points (WALT STEPHENS RD.txt): white edge line on SS-V-ROAD-STRIPE. Regular Polylines, elevation 0.
const string LAYER="SS-V-ROAD-STRIPE";
var RUNS=new (string name,bool closed,Point2d[] pts)[]{
  ("WSR S white line (120-125-156-157)", false, new[]{new Point2d(2271372.4244,1283464.9004),new Point2d(2271450.1969,1283486.7401),new Point2d(2271499.9580,1283502.3317),new Point2d(2271566.2356,1283521.9214)}),
};
Lyr(LAYER,7);
// idempotent: skip if this layer already has linework inside the 261103 point area
int have=0; foreach(ObjectId id in MS){ if(Tx.GetObject(id,OpenMode.ForRead) is Curve c && c.Layer==LAYER){ try{ var e=c.GeometricExtents; if(e.MaxPoint.X>2271300&&e.MinPoint.X<2272000&&e.MaxPoint.Y>1283250&&e.MinPoint.Y<1283700) have++; }catch{} } }
if(have>0){ Log(LAYER+" already has "+have+" curves in the 261103 area - nothing drawn"); Ed.Regen(); return; }
foreach(var r in RUNS){
  var pl=new Polyline(); for(int i=0;i<r.pts.Length;i++) pl.AddVertexAt(i,r.pts[i],0,0,0); pl.Closed=r.closed;
  Put(MS,pl,LAYER); Log(r.name+": "+pl.NumberOfVertices+" v, "+F(pl.Length)+"'"+(r.closed?" closed":"")+" ("+pl.Handle+")");
}
Ed.Regen();

Result

Status
success
Drawing file
C:\Users\sanja\OneDrive\_SurveyDisco\261103 - Ahmed J Ahmed Real Estate Company LLC\261103 - 0 WALT STEPHENS RD.dwg
Message
Executed C3DO-0829 (0 entities touched).
Entities
—
Duration
810 ms
Civil 3D
25.0.0.0

Log

WSR S white line (120-125-156-157): 4 v, 202.039' (21FFF)

Notes

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

No notes yet.