← Inbox

C3D-0035 · READ-ONLY: find the line dividing 30' S.S.E. from Basic : 5 [SHARED-SEG] error

Dumps every parcel segment of 30' S.S.E. and Basic : 5 with handle/layer/endpoints/length, and flags the segments the two share - that shared boundary is what split the 30' easement in two. No changes.

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

C# payload

// READ-ONLY. Find what divides "30' S.S.E." from "Basic : 5" in the SEWER EASEMENT site.
//
// Those two parcels sum to 24157.56 - the area the user measured for the whole 30' easement -
// so topology split one easement into two at some interior line. Dumps every segment of both
// parcels (handle, layer, endpoints, length) and flags the ones the two parcels SHARE, i.e.
// the dividing boundary. Nothing is modified; nothing is deleted.
var civil = CivilApplication.ActiveDocument;

var segs = new List<Tuple<string,string,Point3d,Point3d,double,string>>();

foreach (ObjectId sid in civil.GetSiteIds()) {
    var site = (Site)Tx.GetObject(sid, OpenMode.ForRead);
    if (site.Name != "SEWER EASEMENT") continue;

    foreach (ObjectId pid in site.GetParcelIds()) {
        var p = (Parcel)Tx.GetObject(pid, OpenMode.ForRead);
        if (p.Name != "30' S.S.E." && p.Name != "Basic : 5") continue;

        Log("");
        Log("PARCEL \"" + p.Name + "\"  area=" + p.Area.ToString("F2"));
        foreach (ObjectId segId in p.GetSegmentIds()) {
            var ps = Tx.GetObject(segId, OpenMode.ForRead) as ParcelSegment;
            if (ps == null) continue;
            var a = ps.StartPoint; var b = ps.EndPoint;
            Log(String.Format("  seg [{0}] layer={1} len={2:F2}  ({3:F2},{4:F2}) -> ({5:F2},{6:F2})",
                ps.ObjectId.Handle, ps.Layer, ps.Length, a.X, a.Y, b.X, b.Y));
            segs.Add(Tuple.Create(p.Name, ps.ObjectId.Handle.ToString(), a, b, ps.Length, ps.Layer));
        }
    }
}

// A segment geometrically shared by both parcels IS the dividing line.
Log("");
Log("=== SHARED (the dividing boundary) ===");
Func<Point3d,Point3d,bool> near = (u,v) => u.DistanceTo(v) < 0.05;
int hits = 0;
foreach (var s in segs) {
    if (s.Item1 != "30' S.S.E.") continue;
    foreach (var t in segs) {
        if (t.Item1 != "Basic : 5") continue;
        bool same = (near(s.Item3, t.Item3) && near(s.Item4, t.Item4))
                 || (near(s.Item3, t.Item4) && near(s.Item4, t.Item3));
        if (!same) continue;
        hits++;
        Log(String.Format("  30' seg [{0}] == Basic seg [{1}]  len={2:F2} layer={3}  ({4:F2},{5:F2}) -> ({6:F2},{7:F2})",
            s.Item2, t.Item2, s.Item5, s.Item6, s.Item3.X, s.Item3.Y, s.Item4.X, s.Item4.Y));
    }
}
Log("shared segments: " + hits);

Result

Status
error
Drawing file
C:\Users\sanja\OneDrive\_SurveyDisco\260613 - 5030 E Lake Pkwy, Stockbridge, GA 30281, USA\260612 - CSTORE WATER ABS 30.dwg
Message
Compile error: (21,38): error CS1061: 'Parcel' does not contain a definition for 'GetSegmentIds' and no accessible extension method 'GetSegmentIds' accepting a first argument of type 'Parcel' could be found (are you missing a using directive or an assembly reference?); (26,50): error CS1061: 'ParcelSegment' does not contain a definition for 'Length' and no accessible extension method 'Length' accepting a first argument of type 'ParcelSegment' could be found (are you missing a using directive or an assembly reference?); (27,83): error CS1061: 'ParcelSegment' does not contain a definition for 'Length' and no accessible extension method 'Length' accepting a first argument of type 'ParcelSegment' could be found (are you missing a using directive or an assembly reference?)
Entities
Duration
349 ms
Civil 3D
25.0.0.0

Notes

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

No notes yet.