← Inbox

C3D-0002 · TBC points yellow [TBC-YELLOW] done

Creates point style "TBC Yellow" (marker + label, plan + model, ACI 2) and repoints the TBC point group style override at it. CogoPoint colour comes from the point style, not the layer.

Script file
C3D-0002.cs
Target
SS_BLOCK_22X17 · model space
Author
claude
Approved
yes · reviewer
Timeout
180s

C# payload

// Make the TBC points YELLOW.
//
// CogoPoints ignore their layer colour - the POINT STYLE drives the marker, and the TBC point
// group has IsPointStyleOverridden=True pointing at "Test Pit", so that override is what shows.
// Changing the layer does nothing.
//
// Creates (or reuses) point style "TBC Yellow", sets its Marker + Label display colours to
// yellow (ACI 2) in plan and model, and repoints the TBC group's override at it. "Test Pit" is
// left alone - UTIL, GAS and WALL also use it.
//
// API verified by reflecting AeccDbMgd (the enum is in ...DatabaseServices.Styles, NOT
// Autodesk.Civil):
//   PointStyleCollection.Add(string) -> ObjectId
//   PointStyle.GetDisplayStylePlan(Styles.PointDisplayStyleType) -> DisplayStyle { Color, Layer }
//   PointDisplayStyleType = { Marker, Label }
// Host owns Tx; host regens after commit.
const string STYLE = "TBC Yellow", GROUP = "TBC";
var cd = CivilDoc;

ObjectId sid = ObjectId.Null;
foreach (ObjectId id in cd.Styles.PointStyles) {
    var s0 = Tx.GetObject(id, OpenMode.ForRead) as Autodesk.Civil.DatabaseServices.Styles.PointStyle;
    if (s0 != null && s0.Name == STYLE) { sid = id; break; }
}
if (sid.IsNull) { sid = cd.Styles.PointStyles.Add(STYLE); Log("created point style '" + STYLE + "'"); }
else Log("reusing point style '" + STYLE + "'");

var st = (Autodesk.Civil.DatabaseServices.Styles.PointStyle)Tx.GetObject(sid, OpenMode.ForWrite);
var yellow = Autodesk.AutoCAD.Colors.Color.FromColorIndex(Autodesk.AutoCAD.Colors.ColorMethod.ByAci, 2);

int set = 0;
foreach (Autodesk.Civil.DatabaseServices.Styles.PointDisplayStyleType t in
         System.Enum.GetValues(typeof(Autodesk.Civil.DatabaseServices.Styles.PointDisplayStyleType)))
{
    try { st.GetDisplayStylePlan(t).Color  = yellow; set++; } catch (System.Exception ex) { Log("  plan " + t + ": " + ex.Message); }
    try { st.GetDisplayStyleModel(t).Color = yellow; set++; } catch (System.Exception ex) { Log("  model " + t + ": " + ex.Message); }
}
Log("set " + set + " display colour(s) to yellow (ACI 2) on '" + STYLE + "'");

ObjectId gid = ObjectId.Null;
foreach (ObjectId id in cd.PointGroups) {
    var pg0 = Tx.GetObject(id, OpenMode.ForRead) as PointGroup;
    if (pg0 != null && pg0.Name == GROUP) { gid = id; break; }
}
if (gid.IsNull) { Log("point group '" + GROUP + "' not found"); return; }

var pg = (PointGroup)Tx.GetObject(gid, OpenMode.ForWrite);
pg.IsPointStyleOverridden = true;
pg.PointStyleId = sid;

var chk = (PointGroup)Tx.GetObject(gid, OpenMode.ForRead);
string now = "(none)";
if (!chk.PointStyleId.IsNull) {
    var s2 = Tx.GetObject(chk.PointStyleId, OpenMode.ForRead) as Autodesk.Civil.DatabaseServices.Styles.PointStyle;
    if (s2 != null) now = s2.Name;
}
uint[] nums; try { nums = chk.GetPointNumbers(); } catch { nums = new uint[0]; }
Log("group '" + GROUP + "' (" + nums.Length + " points) -> style '" + now + "', overridden=" +
    chk.IsPointStyleOverridden + (now == STYLE ? "  (verified)" : "  (MISMATCH)"));

Result

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

Log

created point style 'TBC Yellow'
set 4 display colour(s) to yellow (ACI 2) on 'TBC Yellow'
group 'TBC' (184 points) -> style 'TBC Yellow', overridden=True  (verified)

Notes

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

No notes yet.