C3DO-0828 · 261103 linework: edge of pavement (SS-V-ROAD-EP) [C3D-LW1103-EP] done
Draws the edge of pavement from the 261103 field points as regular Polylines on SS-V-ROAD-EP: WSR N EP 122-123-159-188-187. Skips if that layer already has linework in the 261103 area.
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): edge of pavement on SS-V-ROAD-EP. Regular Polylines, elevation 0.
const string LAYER="SS-V-ROAD-EP";
var RUNS=new (string name,bool closed,Point2d[] pts)[]{
("WSR N EP (122-123-159-188-187)", false, new[]{new Point2d(2271368.8027,1283489.6429),new Point2d(2271443.1695,1283511.2641),new Point2d(2271554.9560,1283543.7603),new Point2d(2271622.6947,1283564.2660),new Point2d(2271664.7269,1283588.6190)}),
};
Lyr(LAYER,8);
// 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
Log
layer created SS-V-ROAD-EP WSR N EP (122-123-159-188-187): 5 v, 313.212' (21FFE)
Notes
What worked, what didn't, job-specific gotchas — flagged notes feed the recipes.
No notes yet.