← Inbox

C3D-0001 · TBC points yellow [TBC-YELLOW] error

Creates point style "TBC Yellow" with yellow (ACI 2) plan/model display colours and points the TBC point group style override at it. CogoPoint colour comes from the point style, not the layer.

Script file
C3D-0001.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 controls the marker, and the TBC point
// group has IsPointStyleOverridden=True pointing at the "Test Pit" style, so that override is
// what is being displayed. Changing the layer would do nothing.
//
// Creates (or reuses) a point style "TBC Yellow", sets its plan + model display colours to
// yellow (ACI 2), and points the TBC group's style override at it. "Test Pit" is left alone -
// other groups (UTIL, GAS, WALL) use it too.
//
// API verified by reflecting AeccDbMgd:
//   PointStyleCollection.Add(string) -> ObjectId
//   PointStyle.GetDisplayStylePlan(PointDisplayStyleType) -> DisplayStyle { Color SET, Layer SET }
// 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);

foreach (Autodesk.Civil.PointDisplayStyleType t in
         System.Enum.GetValues(typeof(Autodesk.Civil.PointDisplayStyleType)))
{
    try { var ds = st.GetDisplayStylePlan(t);  ds.Color = yellow; } catch {}
    try { var ds = st.GetDisplayStyleModel(t); ds.Color = yellow; } catch {}
}
try { st.GetLabelDisplayStylePlan().Color  = yellow; } catch {}
try { st.GetLabelDisplayStyleModel().Color = yellow; } catch {}
Log("style '" + STYLE + "' display colours set to yellow (ACI 2)");

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 override = '" + now + "', overridden=" +
    chk.IsPointStyleOverridden + (now == STYLE ? "  (verified)" : "  (MISMATCH)"));

Result

Status
error
Drawing file
C:\Users\sanja\OneDrive\_SurveyDisco\260613 - 5030 E Lake Pkwy, Stockbridge, GA 30281, USA\SS_BLOCK_22X17.dwg
Message
Compile error: (30,54): error CS0234: The type or namespace name 'PointDisplayStyleType' does not exist in the namespace 'Autodesk.Civil' (are you missing an assembly reference?); (29,25): error CS0234: The type or namespace name 'PointDisplayStyleType' does not exist in the namespace 'Autodesk.Civil' (are you missing an assembly reference?)
Entities
—
Duration
306 ms
Civil 3D
25.0.0.0

Notes

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

No notes yet.