C3D-SEGDIST · Segment distances along SEWER_LINE (read-only) done
Find which SSMH points fall along the single 853ft SEWER_LINE run and the real along-line distance between consecutive ones.
C# payload
// READ-ONLY: for the single SEWER_LINE polyline (7007->7013, 853.03ft), find where each of the
// A1-A6/other manhole points falls ALONG the polyline (by parameter/distance-at-closest-point), then
// report the along-line distance between consecutive manholes. Real geometry, not straight-line.
using System;
using System.Linq;
using System.Collections.Generic;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Geometry;
using Autodesk.Civil.ApplicationServices;
using Autodesk.Civil.DatabaseServices;
var db = Db;
var pts = new Dictionary<int, Point3d>();
var cdoc = CivilDocument.GetCivilDocument(db);
using (var tr = db.TransactionManager.StartTransaction())
{
foreach (ObjectId id in cdoc.CogoPoints)
{
var cp = tr.GetObject(id, OpenMode.ForRead) as CogoPoint;
if (cp == null) continue;
int n = (int)cp.PointNumber;
if (n >= 7000 && n <= 7013) pts[n] = new Point3d(cp.Easting, cp.Northing, 0);
}
tr.Commit();
}
using (var tr = db.TransactionManager.StartTransaction())
{
var ms = (BlockTableRecord)tr.GetObject(SymbolUtilityServices.GetBlockModelSpaceId(db), OpenMode.ForRead);
Polyline theLine = null;
foreach (ObjectId id in ms)
{
var e = tr.GetObject(id, OpenMode.ForRead) as Autodesk.AutoCAD.DatabaseServices.Entity;
if (e is Polyline pl && string.Equals(e.Layer, "SEWER_LINE", StringComparison.OrdinalIgnoreCase)) { theLine = pl; break; }
}
if (theLine == null) { Log("no SEWER_LINE polyline"); tr.Commit(); return; }
// for each point within 30ft of the polyline, get its distance-along-curve
var onLine = new List<(int n, double dist)>();
foreach (var kv in pts)
{
try
{
var closest = theLine.GetClosestPointTo(kv.Value, false);
double d = closest.DistanceTo(kv.Value);
if (d > 30) continue; // not actually on this run
double distAlong = theLine.GetDistAtPoint(closest);
onLine.Add((kv.Key, distAlong));
}
catch { }
}
onLine.Sort((a,b) => a.dist.CompareTo(b.dist));
Log($"points found on the SEWER_LINE run ({onLine.Count}), in order along the line:");
foreach (var p in onLine) Log($" pt {p.n} at {p.dist:0.00} ft along line");
Log("SEGMENT LENGTHS (consecutive along-line):");
for (int i = 0; i < onLine.Count - 1; i++)
{
double segLen = onLine[i+1].dist - onLine[i].dist;
Log($" {onLine[i].n} -> {onLine[i+1].n}: {segLen:0.00} ft");
}
tr.Commit();
}
Result
Log
points found on the SEWER_LINE run (0), in order along the line: SEGMENT LENGTHS (consecutive along-line):
Notes
What worked, what didn't, job-specific gotchas — flagged notes feed the recipes.
No notes yet.