← Inbox

C3D-LW-CL · Linework: road centerlines done

Draws 3 centerline polylines on SS-ROAD-CL - two parallel E-W runs (519ft and 230ft, 44ft apart) and one N-S run on the west side. The 21 CL points are three separate roads, not one path.

Script file
C3D-LW-CL.cs
Target
SS_BLOCK_22X17 · model space
Author
claude
Approved
yes · reviewer
Timeout
180s

C# payload

// Road centerline linework -> SS-ROAD-CL.
// The 21 CL points are NOT one path: they fall into three runs - two parallel E-W centerlines
// ~44ft apart (which is the road width, i.e. a divided section or two separate roads) and one
// N-S run on the west side. Chaining all 21 by point number would zigzag between them.
// Regular Polyline (never Polyline3d - cookbook 11), elevation = mean of the run's points.
// Host owns Tx; host regens after commit.
const string LAYER = "SS-ROAD-CL";
var ms = (BlockTableRecord)Tx.GetObject(SymbolUtilityServices.GetBlockModelSpaceId(Db), OpenMode.ForWrite);
EnsureLayer(LAYER, 1);

    {
        var pl = new Polyline();
        pl.AddVertexAt(0, new Point2d(2296744.7, 1280350.98), 0, 0, 0);
        pl.AddVertexAt(1, new Point2d(2296796.75, 1280350.86), 0, 0, 0);
        pl.AddVertexAt(2, new Point2d(2296808.45, 1280350.89), 0, 0, 0);
        pl.AddVertexAt(3, new Point2d(2296867.05, 1280350.41), 0, 0, 0);
        pl.AddVertexAt(4, new Point2d(2296900.27, 1280349.68), 0, 0, 0);
        pl.AddVertexAt(5, new Point2d(2296901.83, 1280349.74), 0, 0, 0);
        pl.AddVertexAt(6, new Point2d(2296965.24, 1280348.62), 0, 0, 0);
        pl.AddVertexAt(7, new Point2d(2296974.76, 1280348.33), 0, 0, 0);
        pl.Closed = false;
        pl.Elevation = 730.73;
        pl.Layer = LAYER;
        ms.AppendEntity(pl);
        Tx.AddNewlyCreatedDBObject(pl, true);
        Log("  CL north (E-W): " + pl.NumberOfVertices + " verts, " + pl.Length.ToString("F1") + " ft");
    }
    {
        var pl = new Polyline();
        pl.AddVertexAt(0, new Point2d(2296449.76, 1280310.67), 0, 0, 0);
        pl.AddVertexAt(1, new Point2d(2296555.75, 1280308.95), 0, 0, 0);
        pl.AddVertexAt(2, new Point2d(2296795.84, 1280306.57), 0, 0, 0);
        pl.AddVertexAt(3, new Point2d(2296807.0, 1280306.6), 0, 0, 0);
        pl.AddVertexAt(4, new Point2d(2296866.76, 1280305.82), 0, 0, 0);
        pl.AddVertexAt(5, new Point2d(2296885.09, 1280305.44), 0, 0, 0);
        pl.AddVertexAt(6, new Point2d(2296899.45, 1280305.35), 0, 0, 0);
        pl.AddVertexAt(7, new Point2d(2296965.34, 1280304.8), 0, 0, 0);
        pl.AddVertexAt(8, new Point2d(2296968.34, 1280304.69), 0, 0, 0);
        pl.Closed = false;
        pl.Elevation = 732.11;
        pl.Layer = LAYER;
        ms.AppendEntity(pl);
        Tx.AddNewlyCreatedDBObject(pl, true);
        Log("  CL south (E-W): " + pl.NumberOfVertices + " verts, " + pl.Length.ToString("F1") + " ft");
    }
    {
        var pl = new Polyline();
        pl.AddVertexAt(0, new Point2d(2296333.76, 1279916.75), 0, 0, 0);
        pl.AddVertexAt(1, new Point2d(2296341.52, 1279962.85), 0, 0, 0);
        pl.AddVertexAt(2, new Point2d(2296345.58, 1280009.74), 0, 0, 0);
        pl.AddVertexAt(3, new Point2d(2296346.44, 1280026.66), 0, 0, 0);
        pl.Closed = false;
        pl.Elevation = 749.16;
        pl.Layer = LAYER;
        ms.AppendEntity(pl);
        Tx.AddNewlyCreatedDBObject(pl, true);
        Log("  CL west (N-S): " + pl.NumberOfVertices + " verts, " + pl.Length.ToString("F1") + " ft");
    }

int n = 0;
foreach (ObjectId id in ms) {
    var e = Tx.GetObject(id, OpenMode.ForRead) as Autodesk.AutoCAD.DatabaseServices.Entity;
    if (e != null && e.Layer == LAYER && e is Polyline) n++;
}
Log("SS-ROAD-CL now holds " + n + " polyline(s) (verified)");

Result

Status
success
Drawing file
C:\Users\sanja\OneDrive\_SurveyDisco\260613 - 5030 E Lake Pkwy, Stockbridge, GA 30281, USA\SS_BLOCK_22X17.dwg
Message
Executed C3D-LW-CL (0 entities touched).
Entities
Duration
358 ms
Civil 3D
25.0.0.0

Log

  CL north (E-W): 8 verts, 230.1 ft
  CL south (E-W): 9 verts, 518.6 ft
  CL west (N-S): 4 verts, 110.8 ft
SS-ROAD-CL now holds 3 polyline(s) (verified)

Notes

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

No notes yet.