← Inbox

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.

Script file
C3D-RELAYER1.cs
Target
SS_Outfall_260612_SHEET.dwg · model space
Author
claude
Approved
yes · reviewer
Timeout
60s

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

Status
success
Drawing file
C:\Users\sanja\OneDrive\_SurveyDisco\260613 - 5030 E Lake Pkwy, Stockbridge, GA 30281, USA\SS_Outfall_260612_SHEET.dwg
Message
Executed C3D-RELAYER1 (0 entities touched).
Entities
Duration
306 ms
Civil 3D
25.0.0.0

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.