← Inbox

C3D-INSP619D · Count lines on layer PARCEL (read-only) done

Entity count by type on layer PARCEL.

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

C# payload

// READ-ONLY: count entities on layer "PARCEL" by type (model space).
using System;
using System.Collections.Generic;
using Autodesk.AutoCAD.DatabaseServices;

var db = Db;
using (var tr = db.TransactionManager.StartTransaction())
{
    var ms = (BlockTableRecord)tr.GetObject(SymbolUtilityServices.GetBlockModelSpaceId(db), OpenMode.ForRead);
    int lines=0, total=0;
    var byType = new SortedDictionary<string,int>(StringComparer.OrdinalIgnoreCase);
    foreach (ObjectId id in ms)
    {
        var e = tr.GetObject(id, OpenMode.ForRead) as Autodesk.AutoCAD.DatabaseServices.Entity;
        if (e == null || !string.Equals(e.Layer, "PARCEL", StringComparison.OrdinalIgnoreCase)) continue;
        total++;
        var tn = e.GetType().Name;
        byType[tn] = byType.TryGetValue(tn, out var c) ? c+1 : 1;
        if (e is Line) lines++;
    }
    Log($"Layer PARCEL: total entities={total}, Line count={lines}");
    foreach (var kv in byType) Log($"  {kv.Key}: {kv.Value}");
    tr.Commit();
}

Result

Status
success
Drawing file
C:\Users\sanja\OneDrive\_SurveyDisco\260619 - 3625 Stonewall Tell Rd, Atlanta, GA 30349, USA\260619 - 3625 Stonewall Tell Rd.dwg
Message
Executed C3D-INSP619D (0 entities touched).
Entities
Duration
315 ms
Civil 3D
25.0.0.0

Log

Layer PARCEL: total entities=19, Line count=19
  Line: 19

Notes

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

No notes yet.