C3D-0377 · Move V-NODE in-block geometry to layer 0 and delete the V-NODE layers [C3D-VNODEKILL] done
Makes every symbol like the control-point example: moves all V-NODE-layer geometry (top-level and inside block definitions) to layer 0 so it inherits each insert's real layer, then deletes the 7 V-NODE layers. Symbols stay whole and connected to their true layers (SEWER_MANHOLE, WATER_VALVE, etc.); the V-NODE layers no longer exist. Verifies none remain.
C# payload
// The HORIZONTAL_AND_VERTICAL_CONTROL_POINT layer is the model: the insert lives on its real
// layer, its guts are NOT parked on V-NODE layers. Make every symbol like that - move all V-NODE
// in-block geometry to "0" (so it inherits the insert's real layer) then delete the V-NODE
// layers entirely. Symbols stay whole and on their true layers.
Log("drawing: " + Db.Filename);
var bt = (BlockTable)Tx.GetObject(Db.BlockTableId, OpenMode.ForRead);
var lt = (LayerTable)Tx.GetObject(Db.LayerTableId, OpenMode.ForWrite);
// the V-NODE layers
var vnode = new List<string>();
foreach (ObjectId id in lt) {
var l = (LayerTableRecord)Tx.GetObject(id, OpenMode.ForRead);
if (l.Name.StartsWith("V-NODE", StringComparison.OrdinalIgnoreCase)) vnode.Add(l.Name);
}
var vset = new HashSet<string>(vnode, StringComparer.OrdinalIgnoreCase);
Log("V-NODE layers: " + vnode.Count);
// thaw/unlock them so their content is editable
foreach (var n in vnode) { var l=(LayerTableRecord)Tx.GetObject(lt[n],OpenMode.ForWrite); l.IsFrozen=false; l.IsOff=false; l.IsLocked=false; }
// move every entity on a V-NODE layer to "0" - top-level AND inside block definitions
int movedTop=0, movedBlk=0;
foreach (ObjectId bid in bt) {
var def = (BlockTableRecord)Tx.GetObject(bid, OpenMode.ForRead);
foreach (ObjectId sid in def) {
var probe = Tx.GetObject(sid, OpenMode.ForRead) as Autodesk.AutoCAD.DatabaseServices.Entity;
if (probe == null || !vset.Contains(probe.Layer)) continue;
var e = (Autodesk.AutoCAD.DatabaseServices.Entity)Tx.GetObject(sid, OpenMode.ForWrite);
e.Layer = "0";
if (def.IsLayout) movedTop++; else movedBlk++;
}
}
Log(string.Format("moved to 0: top-level={0} in-block={1}", movedTop, movedBlk));
// current layer guard, then delete the V-NODE layers
{ var cl=(LayerTableRecord)Tx.GetObject(Db.Clayer,OpenMode.ForRead); if (vset.Contains(cl.Name)) { Db.Clayer=lt["0"]; Log("current layer was V-NODE - switched to 0"); } }
int deleted=0;
foreach (var n in vnode) {
try { var l=(LayerTableRecord)Tx.GetObject(lt[n],OpenMode.ForWrite); l.Erase(); deleted++; }
catch (System.Exception ex) { Log("could not delete " + n + ": " + ex.Message); }
}
Log("deleted " + deleted + " V-NODE layers");
// verify
var lt2 = (LayerTable)Tx.GetObject(Db.LayerTableId, OpenMode.ForRead);
int left=0;
foreach (ObjectId id in lt2) { var l=(LayerTableRecord)Tx.GetObject(id,OpenMode.ForRead); if (l.Name.StartsWith("V-NODE",StringComparison.OrdinalIgnoreCase)) { left++; Log(" STILL: "+l.Name); } }
int stray=0;
foreach (ObjectId bid in bt) {
var def=(BlockTableRecord)Tx.GetObject(bid,OpenMode.ForRead);
foreach (ObjectId sid in def) { var e=Tx.GetObject(sid,OpenMode.ForRead) as Autodesk.AutoCAD.DatabaseServices.Entity; if (e!=null && !e.IsErased && e.Layer.StartsWith("V-NODE",StringComparison.OrdinalIgnoreCase)) stray++; }
}
Log(string.Format("VERIFY: V-NODE layers remaining={0} entities still on V-NODE={1} {2}",
left, stray, (left==0&&stray==0)?"CLEAN":"*** NOT CLEAN ***"));
Ed.Regen();
Result
Log
drawing: C:\Users\sanja\OneDrive\_SurveyDisco\260613 - 5030 E Lake Pkwy, Stockbridge, GA 30281, USA\ACAD-260612-Springdale Sanitary Sewer Extension As-Built 60 wPROFILE.dwg V-NODE layers: 7 moved to 0: top-level=0 in-block=170 deleted 7 V-NODE layers VERIFY: V-NODE layers remaining=0 entities still on V-NODE=0 CLEAN
Notes
What worked, what didn't, job-specific gotchas — flagged notes feed the recipes.
No notes yet.