← Inbox

C3D-CLSW · Redraw CL and sidewalk as Polylines done

CL split into two roads (elev 412 vs 396) and path-ordered; sidewalk split into its two edges (12 pts, not 10). All regular Polylines, replacing Polyline3d.

Script file
C3D-CLSW.cs
Target
active document · model space
Author
claude
Approved
yes · auto-auth
Timeout
60s

C# payload

// Redraw road centerline and sidewalk as regular Polylines (were Polyline3d).
// CL: the 9 CL points are TWO SEPARATE ROADS - 426/433/452/463/466/488/495 sit at elev
// 411-413, while 774/778 sit at elev 396, a 16ft drop. Drawn as two polylines, ordered by
// walking from the far endpoint (nearest-neighbour along the path), so the main CL runs
// between the curb runs like a road instead of zigzagging.
// SW: 12 sidewalk points (not 10 - earlier pass missed 638 and 700). Spacing alternates
// ~6ft then ~17-44ft, i.e. the points are the TWO EDGES of the walk, not a centre path.
// Split by rotating into the walk frame (52.0deg, same as the building) and grouping by
// which side of the midline each point falls on: edge A 5 verts 88.3ft, edge B 7 verts 94.1ft.
// Erases the prior Polyline3d on both layers first.
// Host owns Tx/ModelSpace - no using/Commit here.
int erased = 0;
foreach (ObjectId id in ModelSpace)
{
    var e = Tx.GetObject(id, OpenMode.ForRead) as Autodesk.AutoCAD.DatabaseServices.Entity;
    if (e == null) continue;
    if (e.Layer != "SS-V-ROAD-CNTR" && e.Layer != "SS-V-SIDEWALK") continue;
    if (!(e is Polyline3d)) continue;
    var w = (Autodesk.AutoCAD.DatabaseServices.Entity)Tx.GetObject(id, OpenMode.ForWrite);
    w.Erase();
    erased++;
}
Log($"Erased {erased} Polyline3d from CL/SW layers.");

    {
        var pl = new Polyline();
        pl.AddVertexAt(0, new Point2d(2427880.33, 1064741.96), 0, 0, 0);
        pl.AddVertexAt(1, new Point2d(2427848.48, 1064731.03), 0, 0, 0);
        pl.AddVertexAt(2, new Point2d(2427807.86, 1064716.8), 0, 0, 0);
        pl.AddVertexAt(3, new Point2d(2427745.92, 1064723.83), 0, 0, 0);
        pl.AddVertexAt(4, new Point2d(2427767.33, 1064653.49), 0, 0, 0);
        pl.AddVertexAt(5, new Point2d(2427784.98, 1064594.24), 0, 0, 0);
        pl.AddVertexAt(6, new Point2d(2427778.99, 1064565.27), 0, 0, 0);
        pl.Closed = false;
        pl.Elevation = 412.48;
        pl.Layer = "SS-V-ROAD-CNTR";
        ModelSpace.AppendEntity(pl);
        Tx.AddNewlyCreatedDBObject(pl, true);
        Log($"CL main road: {pl.NumberOfVertices} verts, {pl.Length:F1}ft on 'SS-V-ROAD-CNTR'.");
    }
    {
        var pl = new Polyline();
        pl.AddVertexAt(0, new Point2d(2427796.34, 1064555.31), 0, 0, 0);
        pl.AddVertexAt(1, new Point2d(2427799.17, 1064529.55), 0, 0, 0);
        pl.Closed = false;
        pl.Elevation = 396.06;
        pl.Layer = "SS-V-ROAD-CNTR";
        ModelSpace.AppendEntity(pl);
        Tx.AddNewlyCreatedDBObject(pl, true);
        Log($"CL lower road: {pl.NumberOfVertices} verts, {pl.Length:F1}ft on 'SS-V-ROAD-CNTR'.");
    }
    {
        var pl = new Polyline();
        pl.AddVertexAt(0, new Point2d(2428036.89, 1064429.17), 0, 0, 0);
        pl.AddVertexAt(1, new Point2d(2428047.57, 1064442.85), 0, 0, 0);
        pl.AddVertexAt(2, new Point2d(2428058.11, 1064456.4), 0, 0, 0);
        pl.AddVertexAt(3, new Point2d(2428085.12, 1064491.27), 0, 0, 0);
        pl.AddVertexAt(4, new Point2d(2428091.12, 1064498.89), 0, 0, 0);
        pl.Closed = false;
        pl.Elevation = 419.00;
        pl.Layer = "SS-V-SIDEWALK";
        ModelSpace.AppendEntity(pl);
        Tx.AddNewlyCreatedDBObject(pl, true);
        Log($"SW edge A: {pl.NumberOfVertices} verts, {pl.Length:F1}ft on 'SS-V-SIDEWALK'.");
    }
    {
        var pl = new Polyline();
        pl.AddVertexAt(0, new Point2d(2428029.79, 1064434.49), 0, 0, 0);
        pl.AddVertexAt(1, new Point2d(2428032.23, 1064432.69), 0, 0, 0);
        pl.AddVertexAt(2, new Point2d(2428042.54, 1064446.03), 0, 0, 0);
        pl.AddVertexAt(3, new Point2d(2428053.71, 1064460.02), 0, 0, 0);
        pl.AddVertexAt(4, new Point2d(2428080.41, 1064494.74), 0, 0, 0);
        pl.AddVertexAt(5, new Point2d(2428086.23, 1064502.47), 0, 0, 0);
        pl.AddVertexAt(6, new Point2d(2428084.05, 1064504.31), 0, 0, 0);
        pl.Closed = false;
        pl.Elevation = 419.08;
        pl.Layer = "SS-V-SIDEWALK";
        ModelSpace.AppendEntity(pl);
        Tx.AddNewlyCreatedDBObject(pl, true);
        Log($"SW edge B: {pl.NumberOfVertices} verts, {pl.Length:F1}ft on 'SS-V-SIDEWALK'.");
    }

Result

Status
success
Drawing file
C:\Users\sanja\OneDrive\_SurveyDisco\260709 - 1512 Bass Rd, Macon, GA 31210, USA\260709 - 1512 Bass Rd.dwg
Message
Executed C3D-CLSW (0 entities touched).
Entities
Duration
554 ms
Civil 3D
25.0.0.0

Log

Erased 2 Polyline3d from CL/SW layers.
CL main road: 7 verts, 304.0ft on 'SS-V-ROAD-CNTR'.
CL lower road: 2 verts, 25.9ft on 'SS-V-ROAD-CNTR'.
SW edge A: 5 verts, 88.3ft on 'SS-V-SIDEWALK'.
SW edge B: 7 verts, 94.1ft on 'SS-V-SIDEWALK'.

Notes

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

No notes yet.