C3D-RELAYER1 · Re-layer plan-view content onto HCWA layers done
Move V-CTRL text, V-ESMT-SSE text, V-SSWR-PIPE, V-SSWR-TEXT, V-WTF dims/labels/polyline onto matching HCWA layers. Profile (P-*), grid, and raw CogoPoints untouched.
C# payload
// Re-layer existing plan-view entities onto HCWA layers. Profile (P-*) and grid (V-GRID*) layers
// untouched. Raw CogoPoints untouched (need judgment, not moved yet). Only text/dims/lines/polylines
// that are clearly plan-view sewer/water/control/easement content are moved.
using System;
using System.Collections.Generic;
using Autodesk.AutoCAD.DatabaseServices;
var db = Db;
int moved = 0;
var counts = new Dictionary<string,int>(StringComparer.OrdinalIgnoreCase);
void MoveLayer(Transaction tr, BlockTableRecord ms, string fromLayer, string toLayer, Func<Autodesk.AutoCAD.DatabaseServices.Entity,bool> filter)
{
foreach (ObjectId id in ms)
{
var e = tr.GetObject(id, OpenMode.ForRead) as Autodesk.AutoCAD.DatabaseServices.Entity;
if (e == null || !string.Equals(e.Layer, fromLayer, StringComparison.OrdinalIgnoreCase)) continue;
if (!filter(e)) continue;
var w = (Autodesk.AutoCAD.DatabaseServices.Entity)tr.GetObject(id, OpenMode.ForWrite);
w.Layer = toLayer;
moved++;
counts[toLayer] = counts.TryGetValue(toLayer, out var c) ? c+1 : 1;
}
}
using (var tr = db.TransactionManager.StartTransaction())
{
var ms = (BlockTableRecord)tr.GetObject(SymbolUtilityServices.GetBlockModelSpaceId(db), OpenMode.ForWrite);
MoveLayer(tr, ms, "V-CTRL", "HORIZONTAL_AND_VERTICAL_CONTROL_TEXT", e => e is DBText);
MoveLayer(tr, ms, "V-ESMT-SSE", "SEWER_EASEMENT_TEXT", e => e is DBText);
MoveLayer(tr, ms, "V-SSWR-PIPE", "SEWER_LINE", e => e is Polyline || e is Line);
MoveLayer(tr, ms, "V-SSWR-TEXT", "SEWER_MANHOLE_TEXT", e => e is DBText);
MoveLayer(tr, ms, "V-WTF", "WATER_LINE_TEXT", e => e.GetType().Name == "AlignedDimension" || e.GetType().Name == "GeneralSegmentLabel");
MoveLayer(tr, ms, "V-WTF", "WATER_LINE", e => e is Polyline);
tr.Commit();
}
Log($"moved {moved} entities total:");
foreach (var kv in counts) Log($" {kv.Key}: {kv.Value}");
Log("Untouched: all P-* profile layers, V-GRID/V-GRID-TEXT, and all CogoPoint entities on V-CREEK/V-HIDE/V-PTS-OG/V-WTF (need judgment, not moved).");
Result
Log
moved 40 entities total: HORIZONTAL_AND_VERTICAL_CONTROL_TEXT: 1 SEWER_EASEMENT_TEXT: 1 SEWER_LINE: 1 SEWER_MANHOLE_TEXT: 21 WATER_LINE_TEXT: 15 WATER_LINE: 1 Untouched: all P-* profile layers, V-GRID/V-GRID-TEXT, and all CogoPoint entities on V-CREEK/V-HIDE/V-PTS-OG/V-WTF (need judgment, not moved).
Notes
What worked, what didn't, job-specific gotchas — flagged notes feed the recipes.
No notes yet.