C3DO-0827 · 261103 linework: centerlines (SS-V-ROAD-CNTR) [C3D-LW1103-CL] done
Draws the centerlines from the 261103 field points as regular Polylines on SS-V-ROAD-CNTR: Walt Stephens Rd CL 121-124-160-158-190-181-172; side rd CL 101-105-109. 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): centerlines on SS-V-ROAD-CNTR. Regular Polylines, elevation 0.
const string LAYER="SS-V-ROAD-CNTR";
var RUNS=new (string name,bool closed,Point2d[] pts)[]{
("Walt Stephens Rd CL (121-124-160-158-190-181-172)", false, new[]{new Point2d(2271370.4948,1283476.7725),new Point2d(2271445.9977,1283499.7610),new Point2d(2271449.6611,1283500.6754),new Point2d(2271557.8062,1283531.7681),new Point2d(2271623.5925,1283551.2225),new Point2d(2271715.8871,1283579.5821),new Point2d(2271925.8742,1283640.2859)}),
("side rd CL (101-105-109)", false, new[]{new Point2d(2271496.7053,1283308.6889),new Point2d(2271491.0069,1283342.6265),new Point2d(2271480.0341,1283384.0025)}),
};
Lyr(LAYER,1);
// 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
Walt Stephens Rd CL (121-124-160-158-190-181-172): 7 v, 578.968' (21FFB) side rd CL (101-105-109): 3 v, 77.219' (21FFC)
Notes
What worked, what didn't, job-specific gotchas — flagged notes feed the recipes.
No notes yet.