← Inbox

C3D-0438 · Fix NO C filter (~C-*) done

Rebuild the NO C layer filter with expression NAME==~C-* and verify no C- layers pass.

Script file
C3D-0438.cs
Target
260711 - 281 Maranatha Trail.dwg · model space
Author
claude
Approved
yes · auto-auth
Timeout
60s

C# payload


var fc = Db.LayerFilters;
var root = fc.Root;
var toRemove = new System.Collections.Generic.List<Autodesk.AutoCAD.LayerManager.LayerFilter>();
foreach (Autodesk.AutoCAD.LayerManager.LayerFilter f in root.NestedFilters)
    if (f.Name == "NOT C-*" || f.Name == "NO C") toRemove.Add(f);
foreach (var f in toRemove) root.NestedFilters.Remove(f);
var lf = new Autodesk.AutoCAD.LayerManager.LayerFilter();
lf.Name = "NO C";
lf.FilterExpression = "NAME==\"~C-*\"";
root.NestedFilters.Add(lf);
Db.LayerFilters = fc;
// verify against real layers using the filter object itself
var lt = (LayerTable)Tx.GetObject(Db.LayerTableId, OpenMode.ForRead);
int shown=0; var sampleC=new System.Collections.Generic.List<string>();
foreach (ObjectId id in lt) {
    var lr=(LayerTableRecord)Tx.GetObject(id,OpenMode.ForRead);
    bool member = lf.Filter(lr);
    if (member) { shown++; if (lr.Name.StartsWith("C-")) sampleC.Add(lr.Name); }
}
Log("expr="+lf.FilterExpression+"  shown="+shown+"  C-inFilter="+sampleC.Count);
foreach (var s in sampleC) Log("  STILL SHOWING: "+s);
Ed.Regen();

Result

Status
success
Drawing file
C:\Users\sanja\OneDrive\_SurveyDisco\260711 - 281 Maranatha Trail, Lawrenceville, GA 30045, USA\260711 - 281 Maranatha Trail R2.dwg
Message
Executed C3D-0438 (0 entities touched).
Entities
Duration
532 ms
Civil 3D
25.0.0.0

Log

expr=NAME=="~C-*"  shown=72  C-inFilter=0

Notes

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

No notes yet.