← Inbox

C3D-READCURB · Read whats on the curb layer error

Read-only: every entity on SS-V-ROAD-CURB with vertex count, length, and endpoints.

Script file
C3D-READCURB.cs
Target
active document · model space
Author
claude
Approved
yes · auto-auth
Timeout
60s

C# payload

// READ-ONLY: read what is actually on SS-V-ROAD-CURB in the drawing right now.
const string LAYER = "SS-V-ROAD-CURB";
int n = 0;
foreach (ObjectId id in ModelSpace)
{
    var ent = Tx.GetObject(id, OpenMode.ForRead) as Entity;
    if (ent == null || ent.Layer != LAYER) continue;
    n++;
    var p3 = ent as Polyline3d;
    if (p3 != null)
    {
        var vs = new List<Point3d>();
        foreach (ObjectId vid in p3)
        {
            var v = Tx.GetObject(vid, OpenMode.ForRead) as PolylineVertex3d;
            if (v != null) vs.Add(v.Position);
        }
        double len = 0;
        for (int i = 1; i < vs.Count; i++) len += vs[i].DistanceTo(vs[i-1]);
        var s0 = vs.Count > 0 ? vs[0] : Point3d.Origin;
        var s1 = vs.Count > 0 ? vs[vs.Count-1] : Point3d.Origin;
        Log($"P3D h={ent.Handle} verts={vs.Count} len={len:F1} start=({s0.X:F2},{s0.Y:F2}) end=({s1.X:F2},{s1.Y:F2})");
    }
    else
    {
        Log($"{ent.GetType().Name} h={ent.Handle}");
    }
}
Log($"Total {n} entities on {LAYER}.");

Result

Status
error
Drawing file
C:\Users\sanja\OneDrive\_SurveyDisco\260709 - 1512 Bass Rd, Macon, GA 31210, USA\260709 - 1512 Bass Rd.dwg
Message
Compile error: (6,53): error CS0104: 'Entity' is an ambiguous reference between 'Autodesk.AutoCAD.DatabaseServices.Entity' and 'Autodesk.Civil.DatabaseServices.Entity'
Entities
Duration
317 ms
Civil 3D
25.0.0.0

Notes

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

No notes yet.