← Inbox

C3D-0088 · Populate CURVE DELTA OFF with the ARC/CHD/RAD format [MK-CURVE-STYLE3] done

CopyFrom collided on the source style name, so this writes the text component contents, height and offsets directly from Delta over Length and Radius into CURVE DELTA OFF and sets the Delta component invisible. Contains no erase; verifies the components and their visibility afterwards.

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

C# payload

// Populate "CURVE DELTA OFF" (already created by C3D-0087, currently empty of the right content).
//
// CopyFrom threw "Duplicated Name" because the copied style carries the SOURCE's name and
// collides in the collection. So do not CopyFrom - write the text component contents directly,
// taken verbatim from the source style's components read in C3D-0083.
//
// NO ERASE. The existing style is opened and edited in place.
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;
Log("drawing: " + Db.Filename);

ObjectId srcId = ObjectId.Null, dstId = ObjectId.Null;
foreach (ObjectId sid in curves) {
    var s = Tx.GetObject(sid, OpenMode.ForRead) as Autodesk.Civil.DatabaseServices.Styles.LabelStyle;
    if (s == null) continue;
    if (s.Name == SRC) srcId = sid;
    if (s.Name == DST) dstId = sid;
}
if (srcId.IsNull) { Log("ABORT: source \"" + SRC + "\" missing"); return; }
if (dstId.IsNull)  { dstId = curves.Add(DST); Log("created \"" + DST + "\""); }
else Log("\"" + DST + "\" exists - editing in place");

// read the source components into a map name -> (contents, height, attachment, xoff, yoff)
var src = (Autodesk.Civil.DatabaseServices.Styles.LabelStyle)Tx.GetObject(srcId, OpenMode.ForRead);
var want = new Dictionary<string, object[]>();
foreach (ObjectId cid in src.GetComponents(Autodesk.Civil.DatabaseServices.Styles.LabelStyleComponentType.Text)) {
    var c = Tx.GetObject(cid, OpenMode.ForRead) as Autodesk.Civil.DatabaseServices.Styles.LabelStyleTextComponent;
    if (c == null) continue;
    want[c.Name] = new object[] { c.Text.Contents.Value, c.Text.Height.Value,
                                  c.Text.Attachment.Value, c.Text.XOffset.Value, c.Text.YOffset.Value };
    Log("  source component \"" + c.Name + "\"");
}

var dst = (Autodesk.Civil.DatabaseServices.Styles.LabelStyle)Tx.GetObject(dstId, OpenMode.ForWrite);
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;

    // the format component: copy the ARC/CHD/bearing/RAD template across whatever it is called here
    if (want.ContainsKey(c.Name)) {
        var w = want[c.Name];
        c.Text.Contents.Value   = (string)w[0];
        c.Text.Height.Value     = (double)w[1];
        c.Text.XOffset.Value    = (double)w[3];
        c.Text.YOffset.Value    = (double)w[4];
        Log("  set \"" + c.Name + "\" from source");
    }
    if (c.Name == "Delta") { c.General.Visible.Value = false; Log("  \"Delta\" -> visible=false"); }
}

Log("");
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;
    Log("VERIFY \"" + 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 { }
        if (ct.Length > 70) ct = ct.Substring(0, 70) + "...";
        Log("    \"" + c.Name + "\" visible=" + v + "  " + ct);
    }
}
Ed.Regen();

Result

Status
success
Drawing file
C:\Users\sanja\OneDrive\_SurveyDisco\260613 - 5030 E Lake Pkwy, Stockbridge, GA 30281, USA\260612 - CSTORE WATER ABS 30.dwg
Message
Executed C3D-0088 (0 entities touched).
Entities
Duration
1382 ms
Civil 3D
25.0.0.0

Log

drawing: C:\Users\sanja\OneDrive\_SurveyDisco\260613 - 5030 E Lake Pkwy, Stockbridge, GA 30281, USA\260612 - CSTORE WATER ABS 30.dwg
created "CURVE DELTA OFF"
  source component "Table Tag"
  source component "Distance & Radius"
  source component "Delta"
  set "Table Tag" from source

VERIFY "CURVE DELTA OFF"
    "Table Tag" visible=True  C<[Parcel Curve Number]>
    "Distance and Radius" visible=True  L=<[Segment Length(Uft|P2|RN|Sn|OF|AP|GC|UN)]>, R=<[Segment Radius(Uft...

Notes

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

No notes yet.