← Inbox

C3D-0073 · READ-ONLY: sewer segment lengths, head of the list [SEG-LENGTHS-HEAD] done

Same true-length report restricted to SEWER_LINE, printing the segments before 2EC8A that were truncated, so the 7003 to 7005 mapping can be settled against real geometry. No changes.

Script file
C3D-0073.cs
Target
260612 · model space
Author
claude
Approved
yes · reviewer
Timeout
240s

C# payload

// READ-ONLY. Every sewer segment in the drawing with its true length and endpoints, and which
// survey point (if any) sits at each end. This is the ground truth to match the user's table
// against - I will not assume the earlier mapping was right, two of its rows disagreed on distance.
//
// Reports EVERY line/polyline on SEWER_LINE (and any sewer-ish layer), not just the 14 I labelled,
// in case a segment exists that I never mapped.
var ms = (BlockTableRecord)Tx.GetObject(SymbolUtilityServices.GetBlockModelSpaceId(Db), OpenMode.ForRead);
Func<Func<string>, string> safe = f => { try { return f(); } catch (System.Exception ex) { return "<" + ex.GetType().Name + ">"; } };

// collect the manhole / sewer points so ends can be named
var pts = new List<object[]>();   // number, desc, x, y
foreach (ObjectId id in ms) {
    var cp = Tx.GetObject(id, OpenMode.ForRead) as CogoPoint;
    if (cp == null) continue;
    string d = (safe(() => cp.RawDescription ?? "")).Trim().ToUpper();
    pts.Add(new object[] { cp.PointNumber, d, cp.Easting, cp.Northing });
}

Func<double,double,string> nameAt = (x, y) => {
    string best = ""; double bd = 3.0;
    foreach (var p in pts) {
        double dx = (double)p[2] - x, dy = (double)p[3] - y;
        double dd = Math.Sqrt(dx*dx + dy*dy);
        if (dd < bd) { bd = dd; best = p[0].ToString() + " " + (string)p[1]; }
    }
    return best.Length == 0 ? "(no point)" : best + String.Format(" [{0:F2}ft]", bd);
};

Log("=== SEWER SEGMENTS IN THE DRAWING ===");
int n = 0;
foreach (ObjectId id in ms) {
    Autodesk.AutoCAD.DatabaseServices.DBObject o;
    try { o = Tx.GetObject(id, OpenMode.ForRead); } catch { continue; }
    var ent = o as Autodesk.AutoCAD.DatabaseServices.Entity;
    if (ent == null) continue;
    string lay = safe(() => ent.Layer);
    if (lay != "SEWER_LINE") continue;   // lines only; easement polys already read

    var ln = o as Line;
    var pl = o as Polyline;
    if (ln == null && pl == null) continue;

    if (ln != null) {
        // tail (2EC8A onward) already captured in C3D-0072
        if (String.Compare(o.Handle.ToString(), "2EC8A") >= 0) { n++; continue; }
        n++;
        Log("");
        Log(String.Format("[{0}] Line  layer={1}  LENGTH={2:F2}", o.Handle, lay, ln.Length));
        Log("    start " + String.Format("{0:F2},{1:F2}", ln.StartPoint.X, ln.StartPoint.Y) + "   = " + nameAt(ln.StartPoint.X, ln.StartPoint.Y));
        Log("    end   " + String.Format("{0:F2},{1:F2}", ln.EndPoint.X, ln.EndPoint.Y) + "   = " + nameAt(ln.EndPoint.X, ln.EndPoint.Y));
    } else {
        n++;
        Log("");
        Log(String.Format("[{0}] Polyline  layer={1}  verts={2}  LENGTH={3:F2}  closed={4}",
            o.Handle, lay, pl.NumberOfVertices, pl.Length, pl.Closed));
        for (int i = 0; i < pl.NumberOfVertices && i < 30; i++) {
            var v = pl.GetPoint2dAt(i);
            Log(String.Format("      v{0,-2} {1:F2},{2:F2}   = {3}", i, v.X, v.Y, nameAt(v.X, v.Y)));
        }
    }
}
Log("");
Log("sewer line entities: " + n);

Result

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

Log

=== SEWER SEGMENTS IN THE DRAWING ===

[2E95F] Line  layer=SEWER_LINE  LENGTH=12.07
    start 2296651.99,1280058.10   = 358 SSMH TEST MH [0.00ft]
    end   2296651.97,1280046.04   = (no point)

[2EC86] Line  layer=SEWER_LINE  LENGTH=132.52
    start 2296379.85,1279953.52   = 473 SSMH A16 [0.00ft]
    end   2296511.25,1279951.45   = 424 SSMH A14 [0.00ft]

[2EC87] Line  layer=SEWER_LINE  LENGTH=133.21
    start 2296511.25,1279951.45   = 424 SSMH A14 [0.00ft]
    end   2296604.65,1280046.20   = 377 SSMH A12 [0.00ft]

[2EC88] Line  layer=SEWER_LINE  LENGTH=55.14
    start 2296549.94,1280052.78   = 1132 6 IN PVC STUB [0.00ft]
    end   2296604.65,1280046.20   = 377 SSMH A12 [0.00ft]

[2EC89] Line  layer=SEWER_LINE  LENGTH=86.31
    start 2296604.65,1280046.20   = 377 SSMH A12 [0.00ft]
    end   2296690.96,1280045.90   = 352 SSMH A10 [0.00ft]

sewer line entities: 14

Notes

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

No notes yet.