← Inbox

C3D-LW-GUARDRAIL · Linework: guardrail done

4 surveyed points chained nearest-neighbour, breaking the run at a 200ft gap -> 1 polyline(s). Layer SS-ROAD-GUARDRAIL.

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

C# payload

// GUARDRAIL linework -> SS-ROAD-GUARDRAIL
// 4 surveyed points chained nearest-neighbour, breaking the run at a 200ft gap -> 1 polyline(s).
// Regular Polyline only (never Polyline3d - cookbook 11); elevation = mean of each run.
// Host owns Tx; host regens after commit.
const string LAYER = "SS-ROAD-GUARDRAIL";
var ms = (BlockTableRecord)Tx.GetObject(SymbolUtilityServices.GetBlockModelSpaceId(Db), OpenMode.ForWrite);
EnsureLayer(LAYER, 40);

    {
        var pl = new Polyline();
        pl.AddVertexAt(0, new Point2d(2296901.96, 1280373.76), 0, 0, 0);
        pl.AddVertexAt(1, new Point2d(2296807.8, 1280374.12), 0, 0, 0);
        pl.AddVertexAt(2, new Point2d(2296783.56, 1280374.57), 0, 0, 0);
        pl.AddVertexAt(3, new Point2d(2296751.82, 1280376.79), 0, 0, 0);
        pl.Closed = false;
        pl.Elevation = 732.21;
        pl.Layer = LAYER;
        ms.AppendEntity(pl);
        Tx.AddNewlyCreatedDBObject(pl, true);
        Log("  run 1: " + 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-GUARDRAIL 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-GUARDRAIL (0 entities touched).
Entities
Duration
332 ms
Civil 3D
25.0.0.0

Log

  run 1: 4 verts, 150.2 ft
SS-ROAD-GUARDRAIL now holds 1 polyline(s) (verified)

Notes

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

No notes yet.