← Inbox

C3D-LAYERCOLOR · Recolor the six drawn layers done

Sets a distinct ACI color on SS-V-ROAD-EPVM, X-DRIV-CONC, SS-V-SIDEWALK, SS-V-ROAD-CNTR, SS-V-BLDG-OTLN, SS-V-BLDG-FACE. Layer color only, reads back and verifies, fully reversible.

Script file
C3D-LAYERCOLOR.cs
Target
active document · model space
Author
claude
Approved
yes · auto-auth
Timeout
60s

C# payload

// Set a distinct ACI color on each of the six layers just drawn to. Layer color only - no entity
// is touched, and the change is trivially reversible. Host owns Tx; no using/Commit here.
// Autodesk.AutoCAD.Colors is NOT in ScriptRunner's WithImports, so Color/ColorMethod are qualified.
const string LAYER_EP   = "SS-V-ROAD-EPVM";
const string LAYER_CON  = "X-DRIV-CONC";
const string LAYER_SW   = "SS-V-SIDEWALK";
const string LAYER_CL   = "SS-V-ROAD-CNTR";
const string LAYER_BLDG = "SS-V-BLDG-OTLN";
const string LAYER_FC   = "SS-V-BLDG-FACE";

var wanted = new List<(string name, short aci, string label)> {
    (LAYER_EP,    30, "EP / edge of pavement (orange)"),
    (LAYER_CON,    8, "CON / concrete (grey)"),
    (LAYER_SW,   150, "SW / sidewalk (light blue)"),
    (LAYER_CL,     1, "CL / centerline (red)"),
    (LAYER_BLDG,   3, "BLDG / building outline (green)"),
    (LAYER_FC,     6, "FC / face of curb (magenta)"),
};

var lt = (LayerTable)Tx.GetObject(Db.LayerTableId, OpenMode.ForRead);
foreach (var w in wanted)
{
    if (!lt.Has(w.name)) { Log($"SKIP '{w.name}' - layer not found."); continue; }
    var ltr = (LayerTableRecord)Tx.GetObject(lt[w.name], OpenMode.ForWrite);
    short before = ltr.Color.ColorIndex;
    ltr.Color = Autodesk.AutoCAD.Colors.Color.FromColorIndex(
        Autodesk.AutoCAD.Colors.ColorMethod.ByAci, w.aci);
    short after = ltr.Color.ColorIndex;
    Log($"'{w.name}': color {before} -> {after} ({w.label}){(after == w.aci ? " (verified)" : " (MISMATCH)")}");
}

Result

Status
success
Drawing file
C:\Users\sanja\OneDrive\_SurveyDisco\260709 - 1512 Bass Rd, Macon, GA 31210, USA\260709 - 1512 Bass Rd.dwg
Message
Executed C3D-LAYERCOLOR (0 entities touched).
Entities
Duration
398 ms
Civil 3D
25.0.0.0

Log

'SS-V-ROAD-EPVM': color 7 -> 30 (EP / edge of pavement (orange)) (verified)
'X-DRIV-CONC': color 201 -> 8 (CON / concrete (grey)) (verified)
'SS-V-SIDEWALK': color 7 -> 150 (SW / sidewalk (light blue)) (verified)
'SS-V-ROAD-CNTR': color 1 -> 1 (CL / centerline (red)) (verified)
'SS-V-BLDG-OTLN': color 6 -> 3 (BLDG / building outline (green)) (verified)
'SS-V-BLDG-FACE': color 7 -> 6 (FC / face of curb (magenta)) (verified)

Notes

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

No notes yet.