← Inbox

C3D-ORPHAN · Identify non-main SEWER_LINE tangents (read-only) done

Report lines whose endpoints are far from manholes, with nearest COGO point per endpoint

Script file
C3D-ORPHAN.cs
Target
active document · model space
Author
claude
Approved
yes · claude (read-only inspection)
Timeout
60s

C# payload

// Read-only: identify the SEWER_LINE tangents whose endpoints are far from any manhole.
// Report each line's length + the nearest COGO point (any code) to each endpoint, so we can tell
// sewer mains from laterals/services/easement lines that were swept onto SEWER_LINE.
var bt = (BlockTable)Tx.GetObject(Db.BlockTableId, OpenMode.ForRead);
var ms = (BlockTableRecord)Tx.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForRead);
var mh = new List<Point2d>();
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)); }

var pts = new List<(uint num, string code, Point2d p)>();
foreach (ObjectId id in CivilDoc.CogoPoints) {
    var cp = (Autodesk.Civil.DatabaseServices.CogoPoint)Tx.GetObject(id, OpenMode.ForRead);
    pts.Add((cp.PointNumber, (cp.RawDescription ?? "").Trim(), new Point2d(cp.Easting, cp.Northing)));
}
string Near(Point3d p) {
    var q = new Point2d(p.X, p.Y); double bd = double.MaxValue; string s = "none";
    foreach (var t in pts) { double d = q.GetDistanceTo(t.p); if (d < bd) { bd = d; s = $"#{t.num} '{t.code}' @{d:F1}'"; } }
    return s;
}
double MhDist(Point3d p) {
    var q = new Point2d(p.X, p.Y); double bd = double.MaxValue;
    foreach (var m in mh) { double d = q.GetDistanceTo(m); if (d < bd) bd = d; }
    return bd;
}
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++;
    double a = MhDist(l.StartPoint), b = MhDist(l.EndPoint);
    if (a < 0.01 && b < 0.01) { Log($"line{i}: OK main ({l.Length:F1}') both ends on MH"); continue; }
    Log($"line{i}: SUSPECT len={l.Length:F1}'  startMH={a:F1}' endMH={b:F1}'");
    Log($"    start {Near(l.StartPoint)}");
    Log($"    end   {Near(l.EndPoint)}");
}

Result

Status
success
Drawing file
C:\Users\sanja\OneDrive\_SurveyDisco\260613 - 5030 E Lake Pkwy, Stockbridge, GA 30281, USA\CSTORE WATER ABS-260612_SHEET.dwg
Message
Executed C3D-ORPHAN (0 entities touched).
Entities
Duration
335 ms
Civil 3D
25.0.0.0

Log

line1: OK main (8.5') both ends on MH
line2: SUSPECT len=12.1'  startMH=0.0' endMH=12.1'
    start #1111 'SSMH' @0.0'
    end   #1111 'SSMH' @12.1'
line3: SUSPECT len=55.4'  startMH=0.0' endMH=55.4'
    start #812 'SSMH' @0.0'
    end   #1132 '6 IN PVC STUB' @0.0'
line4: SUSPECT len=79.8'  startMH=0.0' endMH=79.8'
    start #806 'SSMH MD 10.3' @0.0'
    end   #101 'SSMH MD 21.95' @0.0'
line5: SUSPECT len=64.8'  startMH=10.0' endMH=66.1'
    start #812 'SSMH' @10.0'
    end   #1132 '6 IN PVC STUB' @14.1'
line6: SUSPECT len=20.0'  startMH=66.1' endMH=66.1'
    start #1132 '6 IN PVC STUB' @14.1'
    end   #1132 '6 IN PVC STUB' @14.1'
line7: SUSPECT len=44.9'  startMH=22.8' endMH=66.1'
    start #1107 'DI 18 CON PIPE INV 4.73' @16.3'
    end   #1132 '6 IN PVC STUB' @14.1'
line8: OK main (131.2') both ends on MH
line9: OK main (133.2') both ends on MH
line10: OK main (86.2') both ends on MH
line11: OK main (31.1') both ends on MH
line12: OK main (133.6') both ends on MH

Notes

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

No notes yet.