← Inbox

C3D-ESMTCHK · Inspect SS-ESMT-SSE20 contents (read-only) error

Check whether the Site/ParcelSegment on the old easement layer can be re-layered

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

C# payload

// Read-only: inspect what's on SS-ESMT-SSE20. It holds a Site + ParcelSegment (Civil 3D objects),
// which behave differently from plain geometry - a ParcelSegment's layer may be driven by its
// parent Site/Parcel style rather than being directly settable.
var bt = (BlockTable)Tx.GetObject(Db.BlockTableId, OpenMode.ForRead);
var ms = (BlockTableRecord)Tx.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForRead);
foreach (ObjectId id in ms) {
    var o = Tx.GetObject(id, OpenMode.ForRead);
    var e = o as Autodesk.AutoCAD.DatabaseServices.Entity;
    if (e == null || e.Layer != "SS-ESMT-SSE20") continue;
    Log($"{o.GetType().FullName}  handle={e.Handle}  layer={e.Layer}");
    if (o is Autodesk.Civil.DatabaseServices.ParcelSegment ps) {
        try { Log($"   ParcelSegment len={ps.Length:F2} startPt=({ps.StartPoint.X:F2},{ps.StartPoint.Y:F2})"); } catch { }
    }
    if (o is Autodesk.Civil.DatabaseServices.Site st) {
        try { Log($"   Site name='{st.Name}'"); } catch { }
    }
}
// also confirm what already made it onto SEWER_EASEMENT in the first pass
Log("--- SEWER_EASEMENT current contents ---");
foreach (ObjectId id in ms) {
    var o = Tx.GetObject(id, OpenMode.ForRead);
    var e = o as Autodesk.AutoCAD.DatabaseServices.Entity;
    if (e == null || e.Layer != "SEWER_EASEMENT") continue;
    if (o is Polyline pl) Log($"   Polyline closed={pl.Closed} v={pl.NumberOfVertices} len={pl.Length:F1}");
    else if (o is Line ln) Log($"   Line len={ln.Length:F1}");
    else Log($"   {o.GetType().Name}");
}

Result

Status
error
Drawing file
C:\Users\sanja\OneDrive\_SurveyDisco\260613 - 5030 E Lake Pkwy, Stockbridge, GA 30281, USA\CSTORE WATER ABS-260612_SHEET.dwg
Message
Compile error: (12,46): 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
303 ms
Civil 3D
25.0.0.0

Notes

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

No notes yet.