← Inbox

C3D-0128 · READ-ONLY: audit the linework just drawn [LW-AUDIT] done

Lists every polyline on the five linework layers with vertex count and length, flags duplicate consecutive vertices, and detects any polyline drawn twice by an accidentally repeated ticket. No changes.

Script file
C3D-0128.cs
Target
active document · model space
Author
claude
Approved
yes · reviewer
Timeout
180s

C# payload

// READ-ONLY. Every polyline just drawn, per layer, with vertex count, length and whether it has
// a duplicate consecutive vertex - one run logged "275,275" so at least one exists. Also flags
// exact-duplicate polylines in case a ticket ran twice. Nothing is modified.
var ms = (BlockTableRecord)Tx.GetObject(SymbolUtilityServices.GetBlockModelSpaceId(Db), OpenMode.ForRead);
string[] LAYERS = { "SS-V-ROAD-CURB", "SS-V-ROAD-CNTR", "V-STRC-WALL", "X-DRIV-CONC", "SS-V-ROAD-EPVM" };
var want = new HashSet<string>(LAYERS);
var seen = new Dictionary<string,int>();

foreach (ObjectId id in ms) {
    var pl = Tx.GetObject(id, OpenMode.ForRead) as Polyline;
    if (pl == null || !want.Contains(pl.Layer)) continue;

    int dup = 0;
    var key = new System.Text.StringBuilder();
    for (int i = 0; i < pl.NumberOfVertices; i++) {
        var v = pl.GetPoint2dAt(i);
        key.Append(String.Format("{0:F2},{1:F2};", v.X, v.Y));
        if (i > 0) {
            var u = pl.GetPoint2dAt(i-1);
            if (Math.Abs(u.X-v.X) < 0.001 && Math.Abs(u.Y-v.Y) < 0.001) dup++;
        }
    }
    string k = pl.Layer + "|" + key.ToString();
    if (!seen.ContainsKey(k)) seen[k] = 0;
    seen[k]++;
    Log(String.Format("[{0}] {1,-16} verts={2,-3} len={3,8:F2}{4}", pl.Handle, pl.Layer,
        pl.NumberOfVertices, pl.Length, dup > 0 ? "   DUPLICATE VERTEX x" + dup : ""));
}
Log("");
int dupPolys = 0;
foreach (var kv in seen) if (kv.Value > 1) { dupPolys++; Log("IDENTICAL POLYLINE drawn " + kv.Value + " times on " + kv.Key.Split('|')[0]); }
Log("distinct polylines: " + seen.Count + "   duplicated: " + dupPolys);

Result

Status
success
Drawing file
C:\Users\sanja\OneDrive\_SurveyDisco\260802 - 4082 Sweetbriar Ln, Forest Park, GA 30297, USA\260802 - 4082 Sweetbriar Ln.dwg
Message
Executed C3D-0128 (0 entities touched).
Entities
Duration
437 ms
Civil 3D
25.0.0.0

Log

[20AD7] SS-V-ROAD-CNTR   verts=3   len=   70.96
[20AD8] SS-V-ROAD-CNTR   verts=8   len=  191.85
[20AD9] SS-V-ROAD-CURB   verts=4   len=   85.26
[20ADA] SS-V-ROAD-CURB   verts=3   len=   15.05
[20ADB] SS-V-ROAD-CURB   verts=12  len=  180.46
[20ADC] SS-V-ROAD-CURB   verts=9   len=   46.36   DUPLICATE VERTEX x1
[20ADD] SS-V-ROAD-CURB   verts=10  len=  205.61
[20ADE] V-STRC-WALL      verts=2   len=   37.90
[20ADF] V-STRC-WALL      verts=2   len=   10.78
[20AE0] X-DRIV-CONC      verts=5   len=   54.09
[20AE1] X-DRIV-CONC      verts=5   len=   54.09
[20AE2] X-DRIV-CONC      verts=2   len=   15.24
[20AE3] X-DRIV-CONC      verts=2   len=    2.89
[20AE4] X-DRIV-CONC      verts=2   len=    9.57
[20AE5] X-DRIV-CONC      verts=4   len=   68.94
[20AE6] SS-V-ROAD-EPVM   verts=2   len=    2.33

IDENTICAL POLYLINE drawn 2 times on X-DRIV-CONC
distinct polylines: 15   duplicated: 1

Notes

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

No notes yet.