← Inbox

C3D-0085 · Create parcel curve label style CURVE DELTA OFF [MK-CURVE-STYLE] error

Copies Delta over Length and Radius (which emits the ARC/CHD/bearing/RAD format) to a new parcel curve label style named CURVE DELTA OFF, with the Delta text component set invisible. Idempotent - rebuilds if the style already exists - and reads the style back to verify its components and their visibility.

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

C# payload

// Create parcel curve label style "CURVE DELTA OFF".
//
// Copy of "Delta over Length and Radius" - which despite its name emits the ARC/CHD/bearing/RAD
// format the user wants (verified C3D-0083) - with the Delta component turned OFF.
//
// The source style's three components:
//    "Table Tag"        C<[Parcel Curve Number]>                      -> keep
//    "Distance & Radius" ARC-.. CHD-.. <chord dir> RAD-..             -> keep (this is the format)
//    "Delta"            {\fSimplex..}\U+0394 = <delta angle>          -> OFF
//
// Idempotent: if "CURVE DELTA OFF" already exists it is removed and rebuilt, so a re-run does not
// stack duplicates or half-apply.
const string SRC = "Delta over Length and Radius";
const string DST = "CURVE DELTA OFF";

var civil = CivilApplication.ActiveDocument;
var curves = civil.Styles.LabelStyles.ParcelLabelStyles.CurveLabelStyles;

// locate the source
ObjectId srcId = ObjectId.Null;
foreach (ObjectId sid in curves) {
    var s = Tx.GetObject(sid, OpenMode.ForRead) as Autodesk.Civil.DatabaseServices.Styles.LabelStyle;
    if (s != null && s.Name == SRC) { srcId = sid; break; }
}
if (srcId.IsNull) { Log("ABORT: source style \"" + SRC + "\" not found"); return; }

// drop an existing copy so this is idempotent
foreach (ObjectId sid in curves) {
    var s = Tx.GetObject(sid, OpenMode.ForRead) as Autodesk.Civil.DatabaseServices.Styles.LabelStyle;
    if (s == null || s.Name != DST) continue;
    var w = Tx.GetObject(sid, OpenMode.ForWrite);
    w.Erase();
    Log("removed existing \"" + DST + "\"");
    break;
}

// copy it
ObjectId newId = curves.Add(DST);
var dst = (Autodesk.Civil.DatabaseServices.Styles.LabelStyle)Tx.GetObject(newId, OpenMode.ForWrite);
dst.CopyFrom(Tx.GetObject(srcId, OpenMode.ForRead));
dst.Name = DST;

// turn the Delta component off
int off = 0, kept = 0;
foreach (ObjectId cid in dst.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 == "Delta") { c.General.Visible.Value = false; off++; Log("  component \"Delta\" -> visible=false"); }
    else { kept++; Log("  component \"" + c.Name + "\" kept"); }
}

// verify by re-reading the collection
bool found = false; int nComp = 0, nVis = 0;
foreach (ObjectId sid in civil.Styles.LabelStyles.ParcelLabelStyles.CurveLabelStyles) {
    var s = Tx.GetObject(sid, OpenMode.ForRead) as Autodesk.Civil.DatabaseServices.Styles.LabelStyle;
    if (s == null || s.Name != DST) continue;
    found = true;
    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;
        nComp++;
        bool v = true;
        try { v = c.General.Visible.Value; } catch { }
        if (v) nVis++;
        Log("  VERIFY component \"" + c.Name + "\" visible=" + v);
    }
}
Log("");
Log("style \"" + DST + "\" exists=" + found + "  components=" + nComp + "  visible=" + nVis
    + "   (turned off " + off + ", kept " + kept + ")");
Ed.Regen();

Result

Status
error
Drawing file
C:\Users\sanja\OneDrive\_SurveyDisco\260619 - 3625 Stonewall Tell Rd, Atlanta, GA 30349, USA\260619 - 3625 Stonewall Tell Rd.dwg
Message
Duplicated Name.
Entities
Duration
332 ms
Civil 3D
25.0.0.0

Notes

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

No notes yet.