C3D-LW-WATER · Linework: water done
23 surveyed points chained nearest-neighbour, breaking the run at a 200ft gap -> 2 polyline(s). Layer WATER_LINE_EXISTING.
C# payload
// WATER linework -> WATER_LINE_EXISTING
// 23 surveyed points chained nearest-neighbour, breaking the run at a 200ft gap -> 2 polyline(s).
// Regular Polyline only (never Polyline3d - cookbook 11); elevation = mean of each run.
// Host owns Tx; host regens after commit.
const string LAYER = "WATER_LINE_EXISTING";
var ms = (BlockTableRecord)Tx.GetObject(SymbolUtilityServices.GetBlockModelSpaceId(Db), OpenMode.ForWrite);
EnsureLayer(LAYER, 5);
{
var pl = new Polyline();
pl.AddVertexAt(0, new Point2d(2296695.46, 1280036.24), 0, 0, 0);
pl.AddVertexAt(1, new Point2d(2296654.92, 1280019.68), 0, 0, 0);
pl.AddVertexAt(2, new Point2d(2296654.82, 1280081.99), 0, 0, 0);
pl.AddVertexAt(3, new Point2d(2296595.39, 1280069.34), 0, 0, 0);
pl.AddVertexAt(4, new Point2d(2296563.12, 1280064.91), 0, 0, 0);
pl.AddVertexAt(5, new Point2d(2296560.3, 1280063.04), 0, 0, 0);
pl.AddVertexAt(6, new Point2d(2296560.02, 1280062.86), 0, 0, 0);
pl.AddVertexAt(7, new Point2d(2296556.1, 1280062.29), 0, 0, 0);
pl.AddVertexAt(8, new Point2d(2296362.44, 1280061.51), 0, 0, 0);
pl.AddVertexAt(9, new Point2d(2296332.81, 1280063.26), 0, 0, 0);
pl.AddVertexAt(10, new Point2d(2296331.55, 1280098.75), 0, 0, 0);
pl.AddVertexAt(11, new Point2d(2296364.48, 1280101.58), 0, 0, 0);
pl.AddVertexAt(12, new Point2d(2296360.12, 1280029.33), 0, 0, 0);
pl.AddVertexAt(13, new Point2d(2296332.8, 1280010.93), 0, 0, 0);
pl.AddVertexAt(14, new Point2d(2296328.4, 1279962.96), 0, 0, 0);
pl.AddVertexAt(15, new Point2d(2296321.4, 1279919.82), 0, 0, 0);
pl.Closed = false;
pl.Elevation = 738.53;
pl.Layer = LAYER;
ms.AppendEntity(pl);
Tx.AddNewlyCreatedDBObject(pl, true);
Log(" run 1: " + pl.NumberOfVertices + " verts, " + pl.Length.ToString("F1") + " ft");
}
{
var pl = new Polyline();
pl.AddVertexAt(0, new Point2d(2296365.94, 1280209.9), 0, 0, 0);
pl.AddVertexAt(1, new Point2d(2296370.98, 1280246.89), 0, 0, 0);
pl.AddVertexAt(2, new Point2d(2296380.97, 1280268.68), 0, 0, 0);
pl.AddVertexAt(3, new Point2d(2296399.42, 1280283.57), 0, 0, 0);
pl.AddVertexAt(4, new Point2d(2296433.58, 1280296.07), 0, 0, 0);
pl.AddVertexAt(5, new Point2d(2296454.37, 1280297.92), 0, 0, 0);
pl.AddVertexAt(6, new Point2d(2296556.11, 1280296.73), 0, 0, 0);
pl.Closed = false;
pl.Elevation = 743.07;
pl.Layer = LAYER;
ms.AppendEntity(pl);
Tx.AddNewlyCreatedDBObject(pl, true);
Log(" run 2: " + 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("WATER_LINE_EXISTING now holds " + n + " polyline(s) (verified)");
Result
Log
run 1: 16 verts, 696.2 ft run 2: 7 verts, 244.0 ft WATER_LINE_EXISTING now holds 2 polyline(s) (verified)
Notes
What worked, what didn't, job-specific gotchas — flagged notes feed the recipes.
No notes yet.