C3D-0095 · Create DELTA OFF curve label style in both collections [PUT-DELTA-OFF] done
Creates the DELTA OFF curve label style in the active drawing in both the Parcel curve collection and the General curve collection, with the ARC/CHD/bearing/RAD format, captured heights and offsets, and the Closed filled leader. Contains no erase; verifies both collections afterwards.
C# payload
// Create "DELTA OFF" curve label style in BOTH collections of the active drawing:
// civil.Styles.LabelStyles.ParcelLabelStyles.CurveLabelStyles
// civil.Styles.LabelStyles.GeneralCurveLabelStyles <- sits directly on LabelStyles
//
// Values captured from the user's DELTA OFF style (C3D-0093):
// "Table Tag" C<[Parcel Curve Number]> visible, Y +0.0020833
// "Distance & Radius" ARC/CHD/chord-dir/RAD visible, Y -0.0020833
// "Delta" delta angle INVISIBLE, Y +0.0020833
// height 0.0083333, colour BYLAYER, leader Closed filled 0.0083333
//
// The format string is a @"" verbatim literal - \P is the MText newline code (cookbook 13).
// NO ERASE. If the style already exists in a collection it is edited in place.
const string DST = "DELTA OFF";
const double H = 0.008333333333333333;
const double DY = 0.0020833333333333333;
const string FMT = @"ARC-<[Segment Length(Uft|P2|RN|AP|Sn|OF)]>'\PCHD-<[Segment Chord Length(Uft|P2|RN|AP|GC|UN|Sn|OF)]>'\P<[Segment Chord Direction(Udeg|FDMSdSp|MB|P4|RN|DSn|CU|AP|EN|DZY|OF)]>\PRAD-<[Segment Radius(Uft|P2|RN|AP|Sn|OF)]>'";
const string DELTA_FMT = @"{\fSimplex|b0|i0|c161|p2;\U+0394\fSimplex|b0|i0|c0|p0;=}<[Segment Delta Angle(Udeg|FD|P2|RN|AP|OF)]>";
var civil = CivilApplication.ActiveDocument;
Log("drawing: " + Db.Filename);
Action<Autodesk.Civil.DatabaseServices.Styles.LabelStyleCollection, string> build = (coll, label) => {
ObjectId id = ObjectId.Null;
foreach (ObjectId sid in coll) {
var s0 = Tx.GetObject(sid, OpenMode.ForRead) as Autodesk.Civil.DatabaseServices.Styles.LabelStyle;
if (s0 != null && !s0.IsErased && s0.Name == DST) { id = sid; break; }
}
if (id.IsNull) { id = coll.Add(DST); Log(label + ": created \"" + DST + "\""); }
else Log(label + ": \"" + DST + "\" exists - editing in place");
var st = (Autodesk.Civil.DatabaseServices.Styles.LabelStyle)Tx.GetObject(id, OpenMode.ForWrite);
// the inherited component (from Standard) becomes the ARC/CHD/RAD one
bool wroteFmt = false;
foreach (ObjectId cid in st.GetComponents(Autodesk.Civil.DatabaseServices.Styles.LabelStyleComponentType.Text)) {
var c = Tx.GetObject(cid, OpenMode.ForWrite) as Autodesk.Civil.DatabaseServices.Styles.LabelStyleTextComponent;
if (c == null) continue;
if (c.Name == "Table Tag") {
c.Text.Height.Value = H;
c.Text.YOffset.Value = DY;
continue;
}
if (!wroteFmt) {
c.Text.Contents.Value = FMT;
c.Text.Height.Value = H;
c.Text.XOffset.Value = 0.0;
c.Text.YOffset.Value = -DY;
wroteFmt = true;
Log(" format written to component \"" + c.Name + "\"");
}
}
if (!wroteFmt) Log(" WARNING: no non-tag text component found to hold the format");
// leader
try {
st.Properties.Leader.Visibility.Value = true;
st.Properties.Leader.ArrowheadSize.Value = H;
st.Properties.Leader.ArrowheadStyle.Value = "Closed filled";
} catch (System.Exception ex) { Log(" leader: " + ex.Message); }
};
build(civil.Styles.LabelStyles.ParcelLabelStyles.CurveLabelStyles, "PARCEL ");
build(civil.Styles.LabelStyles.GeneralCurveLabelStyles, "GENERAL");
// verify both
Log("");
Action<Autodesk.Civil.DatabaseServices.Styles.LabelStyleCollection, string> check = (coll, label) => {
foreach (ObjectId sid in coll) {
var s = Tx.GetObject(sid, OpenMode.ForRead) as Autodesk.Civil.DatabaseServices.Styles.LabelStyle;
if (s == null || s.IsErased || s.Name != DST) continue;
Log("VERIFY " + label + " \"" + s.Name + "\"");
foreach (ObjectId cid in s.GetComponents(Autodesk.Civil.DatabaseServices.Styles.LabelStyleComponentType.Text)) {
var c = Tx.GetObject(cid, OpenMode.ForRead) as Autodesk.Civil.DatabaseServices.Styles.LabelStyleTextComponent;
if (c == null) continue;
bool v = true; try { v = c.General.Visible.Value; } catch { }
string ct = ""; try { ct = c.Text.Contents.Value; } catch { }
Log(" \"" + c.Name + "\" visible=" + v + " " + (ct.Length > 60 ? ct.Substring(0,60) + "..." : ct));
}
}
};
check(civil.Styles.LabelStyles.ParcelLabelStyles.CurveLabelStyles, "PARCEL ");
check(civil.Styles.LabelStyles.GeneralCurveLabelStyles, "GENERAL");
Ed.Regen();
Result
Log
drawing: C:\Users\sanja\OneDrive\_SurveyDisco\SS_BLOCK_11X17.dwg
PARCEL : created "DELTA OFF"
format written to component "Distance and Radius"
GENERAL: created "DELTA OFF"
format written to component "Distance and Radius"
VERIFY PARCEL "DELTA OFF"
"Table Tag" visible=True C<[Parcel Curve Number(Sn|GC|UN)]>
"Distance and Radius" visible=True ARC-<[Segment Length(Uft|P2|RN|AP|Sn|OF)]>'\PCHD-<[Segment C...
VERIFY GENERAL "DELTA OFF"
"Table Tag" visible=True C<[Label Tag Number(Sn|GC|UN)]>
"Distance and Radius" visible=True ARC-<[Segment Length(Uft|P2|RN|AP|Sn|OF)]>'\PCHD-<[Segment C...Notes
What worked, what didn't, job-specific gotchas — flagged notes feed the recipes.
No notes yet.