C3D-0448 · Tally parcel label layers + viewport numbers (read-only) error
Count model-space Civil label entities by type and layer, and list real viewport numbers on the 11X17 layout.
C# payload
var nameById=new System.Collections.Generic.Dictionary<ObjectId,string>();
var lt=(LayerTable)Tx.GetObject(Db.LayerTableId,OpenMode.ForRead);
foreach (ObjectId id in lt){ var lr=(LayerTableRecord)Tx.GetObject(id,OpenMode.ForRead); nameById[id]=lr.Name; }
// collect all parcel label entities in model space, tally their layers
var ms=(BlockTableRecord)Tx.GetObject(SymbolUtilityServices.GetBlockModelSpaceId(Db),OpenMode.ForRead);
var tally=new System.Collections.Generic.Dictionary<string,int>();
int labels=0;
foreach(ObjectId eid in ms){
var ent=Tx.GetObject(eid,OpenMode.ForRead) as Entity;
if(ent==null) continue;
string tn=ent.GetType().Name;
if(tn.IndexOf("Label",StringComparison.OrdinalIgnoreCase)>=0){
labels++;
string key=tn+" @ "+ent.Layer;
if(!tally.ContainsKey(key)) tally[key]=0; tally[key]++;
}
}
Log("model-space label entities: "+labels);
foreach(var kv in tally) Log(" "+kv.Key+" x"+kv.Value);
// real viewport numbers + frozen label-bearing layers
var lm=(DBDictionary)Tx.GetObject(Db.LayoutDictionaryId,OpenMode.ForRead);
foreach (System.Collections.DictionaryEntry de in lm){
string lname=(string)de.Key;
if(!lname.ToUpper().Contains("11X17")) continue;
var lay=(Layout)Tx.GetObject((ObjectId)de.Value,OpenMode.ForRead);
var btr=(BlockTableRecord)Tx.GetObject(lay.BlockTableRecordId,OpenMode.ForRead);
int vpi=0;
foreach (ObjectId eid in btr){
var vp=Tx.GetObject(eid,OpenMode.ForRead) as Viewport;
if(vp==null) continue;
vpi++;
Log("VP index "+vpi+" number="+vp.Number+" on="+vp.On+" clipped="+(vp.NonRectClipEntityId!=ObjectId.Null));
}
}
Result
Notes
What worked, what didn't, job-specific gotchas — flagged notes feed the recipes.
No notes yet.