C3D-SNAPCHK · Measure sewer endpoint gaps (read-only) done
Distance from each SEWER_LINE endpoint to nearest manhole center
C# payload
// Read-only: measure the distance from every SEWER_LINE endpoint to the nearest SEWER_MANHOLE
// center, so we know the real gap sizes before choosing a snap tolerance.
var bt = (BlockTable)Tx.GetObject(Db.BlockTableId, OpenMode.ForRead);
var ms = (BlockTableRecord)Tx.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForRead);
var mh = new List<(Point2d c, double r)>();
foreach (ObjectId id in ms) {
var o = Tx.GetObject(id, OpenMode.ForRead);
if (o is Circle c && c.Layer == "SEWER_MANHOLE") mh.Add((new Point2d(c.Center.X, c.Center.Y), c.Radius));
}
Log($"manholes: {mh.Count}");
foreach (var m in mh) Log($" MH @({m.c.X:F2},{m.c.Y:F2}) r={m.r:F2}");
Log("--- SEWER_LINE endpoints -> nearest MH ---");
int i = 0;
foreach (ObjectId id in ms) {
var o = Tx.GetObject(id, OpenMode.ForRead);
if (!(o is Line l) || l.Layer != "SEWER_LINE") continue;
i++;
foreach (var (label, p) in new[]{("start", l.StartPoint), ("end", l.EndPoint)}) {
var q = new Point2d(p.X, p.Y); double bd = double.MaxValue; Point2d best = q;
foreach (var m in mh) { double d = q.GetDistanceTo(m.c); if (d < bd) { bd = d; best = m.c; } }
Log($" line{i} {label} ({p.X:F2},{p.Y:F2}) -> nearest MH {bd:F2}' away");
}
}
Log($"SEWER_LINE count: {i}");
Result
Log
manholes: 8 MH @(2296379.89,1279953.45) r=2.00 MH @(2296511.06,1279951.56) r=2.00 MH @(2296604.89,1280046.15) r=2.00 MH @(2296652.15,1280058.09) r=2.00 MH @(2296685.40,1280052.25) r=2.00 MH @(2296691.10,1280045.90) r=2.00 MH @(2296714.14,1280025.06) r=2.00 MH @(2296827.27,1280096.07) r=2.00 --- SEWER_LINE endpoints -> nearest MH --- line1 start (2296691.10,1280045.90) -> nearest MH 0.00' away line1 end (2296685.40,1280052.25) -> nearest MH 0.00' away line2 start (2296652.15,1280058.09) -> nearest MH 0.00' away line2 end (2296652.51,1280046.01) -> nearest MH 12.08' away line3 start (2296604.89,1280046.15) -> nearest MH 0.00' away line3 end (2296549.94,1280052.78) -> nearest MH 55.35' away line4 start (2296827.27,1280096.07) -> nearest MH 0.00' away line4 end (2296877.74,1280034.32) -> nearest MH 79.75' away line5 start (2296605.51,1280056.15) -> nearest MH 10.02' away line5 end (2296541.20,1280063.90) -> nearest MH 66.11' away line6 start (2296538.81,1280044.04) -> nearest MH 66.11' away line6 end (2296541.20,1280063.90) -> nearest MH 66.11' away line7 start (2296583.39,1280038.67) -> nearest MH 22.77' away line7 end (2296538.81,1280044.04) -> nearest MH 66.11' away line8 start (2296379.89,1279953.45) -> nearest MH 0.00' away line8 end (2296511.06,1279951.56) -> nearest MH 0.00' away line9 start (2296511.06,1279951.56) -> nearest MH 0.00' away line9 end (2296604.89,1280046.15) -> nearest MH 0.00' away line10 start (2296604.89,1280046.15) -> nearest MH 0.00' away line10 end (2296691.10,1280045.90) -> nearest MH 0.00' away line11 start (2296691.10,1280045.90) -> nearest MH 0.00' away line11 end (2296714.14,1280025.06) -> nearest MH 0.00' away line12 start (2296714.14,1280025.06) -> nearest MH 0.00' away line12 end (2296827.27,1280096.07) -> nearest MH 0.00' away SEWER_LINE count: 12
Notes
What worked, what didn't, job-specific gotchas — flagged notes feed the recipes.
No notes yet.