← Inbox

C3D-ROADPTS · 358 existing linework from points (CL/EP/driveway) done

Connect survey points into road CL, EP, driveway

Script file
C3D-ROADPTS.cs
Target
active document · model space
Author
claude
Approved
yes · claude (session)
Timeout
60s

C# payload

// Connect existing survey points into linework: road CL, edge of pavement (EP), driveway.
// Nearest-neighbor chaining per feature (draft).
var bt = (BlockTable)Tx.GetObject(Db.BlockTableId, OpenMode.ForRead);
var ms = (BlockTableRecord)Tx.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite);
var cd = CivilDoc; var cps = cd.CogoPoints;

var CL = new List<Point2d>(); var EP = new List<Point2d>(); var DW = new List<Point2d>();
foreach (ObjectId id in cps) {
    var cp = (Autodesk.Civil.DatabaseServices.CogoPoint)Tx.GetObject(id, OpenMode.ForRead);
    var d = (cp.RawDescription ?? "").ToUpperInvariant().Trim();
    var pt = new Point2d(cp.Easting, cp.Northing);
    if (d == "CL" || d == "CL CL") CL.Add(pt);
    else if (d == "EP") EP.Add(pt);
    else if (d.Contains("DWY") || d.Contains("DYW")) DW.Add(pt);
}
List<Point2d> Chain(List<Point2d> pts) {
    if (pts.Count < 2) return pts;
    var rem = new List<Point2d>(pts); var res = new List<Point2d>();
    var start = rem.OrderBy(p => p.X + p.Y).First(); res.Add(start); rem.Remove(start);
    while (rem.Count > 0) { var last = res[res.Count - 1]; var nxt = rem.OrderBy(p => last.GetDistanceTo(p)).First(); res.Add(nxt); rem.Remove(nxt); }
    return res;
}
void Draw(List<Point2d> pts, string layer, short color) {
    if (pts.Count < 2) { Log($"{layer}: <2 pts, skip"); return; }
    EnsureLayer(layer, color); var c = Chain(pts);
    var pl = new Polyline(); for (int i = 0; i < c.Count; i++) pl.AddVertexAt(i, c[i], 0, 0, 0); pl.Layer = layer;
    ms.AppendEntity(pl); Tx.AddNewlyCreatedDBObject(pl, true); Log($"{layer}: {c.Count} pts");
}
Draw(CL, "SS-V-ROAD-CNTR", 3);
Draw(EP, "SS-V-ROAD-EPVM", 1);
Draw(DW, "SS-V-DRIVE", 8);
Log("Existing road/driveway linework from points complete.");

Result

Status
success
Drawing file
C:\Users\sanja\OneDrive\_SurveyDisco\260702 - 358 St Johns Ave SW, Atlanta, GA 30315, USA\260702 - 358 St Johns Ave SW.dwg
Message
Executed C3D-ROADPTS (0 entities touched).
Entities
Duration
466 ms
Civil 3D
25.0.0.0

Log

SS-V-ROAD-CNTR: 6 pts
SS-V-ROAD-EPVM: 5 pts
SS-V-DRIVE: 22 pts
Existing road/driveway linework from points complete.

Notes

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

No notes yet.