C3D-INSP619D · Count lines on layer PARCEL (read-only) done
Entity count by type on layer PARCEL.
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
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.