← Inbox

C3D-0081 · READ-ONLY: find the curve label style behind the ARC/CHD/RAD labels [CURVE-STYLE-FIND3] done

Reports each curve label type with its style name and parent, and enumerates the parcel line and curve label style collections, to identify the style definition to recreate in another drawing. No changes.

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

C# payload

// READ-ONLY. Find WHERE the curve label format lives so it can be recreated in another drawing.
//
// The four-line ARC/CHD/bearing/RAD label is an instance of a Civil label STYLE. What has to be
// captured is the style definition - its name, which style collection owns it, and the settings
// that produce the leader. Find the label, then name the style behind it.
//
// LabelStyleCollection IS the collection - it has no .LabelStyles member; iterate it directly.
// Read one curve label and report: its concrete type, its style name, and the owning collection.
// Nothing is modified.
var ms = (BlockTableRecord)Tx.GetObject(SymbolUtilityServices.GetBlockModelSpaceId(Db), OpenMode.ForRead);
Func<Func<string>, string> safe = f => { try { return f(); } catch (System.Exception ex) { return "<" + ex.GetType().Name + ">"; } };

Log("=== curve-ish labels in model space ===");
int n = 0;
foreach (ObjectId id in ms) {
    var lbl = Tx.GetObject(id, OpenMode.ForRead) as Autodesk.Civil.DatabaseServices.Label;
    if (lbl == null) continue;
    string tn = lbl.GetType().Name;
    // curve labels: ParcelSegmentLabel on an arc, GeneralSegmentLabel, CurveLabel...
    if (tn.IndexOf("Segment") < 0 && tn.IndexOf("Curve") < 0) continue;
    n++;
    if (n > 12) continue;
    var ent = (Autodesk.AutoCAD.DatabaseServices.Entity)lbl;
    Log("");
    Log("[" + lbl.Handle + "] " + tn + "  layer=" + safe(() => ent.Layer));
    Log("    StyleName  " + safe(() => lbl.StyleName));
    Log("    StyleId    " + safe(() => lbl.StyleId.ToString()));
    try {
        var par = Tx.GetObject(lbl.FeatureId, OpenMode.ForRead);
        Log("    parent     " + par.GetType().Name + " [" + par.Handle + "]");
        var pseg = par as ParcelSegment;
        if (pseg != null) Log("    parent curve? BaseCurve=" + safe(() => pseg.BaseCurve.GetType().Name));
    } catch (System.Exception ex) { Log("    parent: " + ex.Message); }
}
Log("");
Log("total segment/curve labels: " + n);

// where the STYLE definitions live
var civil = CivilApplication.ActiveDocument;
Log("");
Log("=== label style collections ===");
try {
    var pls = civil.Styles.LabelStyles.ParcelLabelStyles;
    Log("  ParcelLabelStyles.LineLabelStyles:");
    foreach (ObjectId sid in pls.LineLabelStyles)
        Log("     " + safe(() => ((Autodesk.Civil.DatabaseServices.Styles.StyleBase)Tx.GetObject(sid, OpenMode.ForRead)).Name));
    Log("  ParcelLabelStyles.CurveLabelStyles:");
    foreach (ObjectId sid in pls.CurveLabelStyles)
        Log("     " + safe(() => ((Autodesk.Civil.DatabaseServices.Styles.StyleBase)Tx.GetObject(sid, OpenMode.ForRead)).Name));
} catch (System.Exception ex) { Log("  parcel label styles: " + ex.Message); }

// (GeneralLabelStyles does not exist on LabelStylesRoot - not guessing further; the
//  label's own StyleName above identifies the style regardless of which collection owns it.)

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-0081 (0 entities touched).
Entities
Duration
358 ms
Civil 3D
25.0.0.0

Log

=== curve-ish labels in model space ===

[2E1ED] ParcelSegmentLabel  layer=C-PROP-LINE-TEXT
    StyleName  Bearing over Distance
    StyleId    (2042933173408)
    parent     ParcelSegment [2E1EB]
    parent curve? BaseCurve=Polyline

[2E1EE] ParcelSegmentLabel  layer=C-PROP-LINE-TEXT
    StyleName  Bearing over Distance
    StyleId    (2042933173408)
    parent     ParcelSegment [2E1EB]
    parent curve? BaseCurve=Polyline

[2E1EF] ParcelSegmentLabel  layer=C-PROP-LINE-TEXT
    StyleName  Delta over Length and Radius
    StyleId    (2042933173776)
    parent     ParcelSegment [2E1EB]
    parent curve? BaseCurve=Polyline

[2E1F0] ParcelSegmentLabel  layer=C-PROP-LINE-TEXT
    StyleName  Delta over Length and Radius
    StyleId    (2042933173776)
    parent     ParcelSegment [2E1EB]
    parent curve? BaseCurve=Polyline

[2E1F1] ParcelSegmentLabel  layer=C-PROP-LINE-TEXT
    StyleName  Delta over Length and Radius
    StyleId    (2042933173776)
    parent     ParcelSegment [2E1EB]
    parent curve? BaseCurve=Polyline

[2E1F2] ParcelSegmentLabel  layer=C-PROP-LINE-TEXT
    StyleName  Delta over Length and Radius
    StyleId    (2042933173776)
    parent     ParcelSegment [2E1EB]
    parent curve? BaseCurve=Polyline

[2E1F3] ParcelSegmentLabel  layer=C-PROP-LINE-TEXT
    StyleName  Bearing over Distance
    StyleId    (2042933173408)
    parent     ParcelSegment [2E1EB]
    parent curve? BaseCurve=Polyline

[2E1F4] ParcelSegmentLabel  layer=C-PROP-LINE-TEXT
    StyleName  Bearing over Distance
    StyleId    (2042933173408)
    parent     ParcelSegment [2E1EB]
    parent curve? BaseCurve=Polyline

[2EE59] ParcelSegmentLabel  layer=SEWER_EASEMENT_TEXT
    StyleName  Standard.Tag.2
    StyleId    (2356176775888)
    parent     ParcelSegment [2EE56]
    parent curve? BaseCurve=Polyline

[2EE5A] ParcelSegmentLabel  layer=SEWER_EASEMENT_TEXT
    StyleName  Standard.Tag.2
    StyleId    (2356176775888)
    parent     ParcelSegment [2EE56]
    parent curve? BaseCurve=Polyline

[2EE5B] ParcelSegmentLabel  layer=SEWER_EASEMENT_TEXT
    StyleName  Standard.Tag.2
    StyleId    (2356176775888)
    parent     ParcelSegment [2EE56]
    parent curve? BaseCurve=Polyline

[2EE5C] ParcelSegmentLabel  layer=SEWER_EASEMENT_TEXT
    StyleName  Standard.Tag.2
    StyleId    (2356176775888)
    parent     ParcelSegment [2EE56]
    parent curve? BaseCurve=Polyline

total segment/curve labels: 37

=== label style collections ===
  ParcelLabelStyles.LineLabelStyles:
     (Span)  Bearing and Distance with Crows Feet
     Overall Distance and Bearing
     Iron Pipe Node Label
     Bearing over Distance
     Standard
  ParcelLabelStyles.CurveLabelStyles:
     Delta over Length and Radius
     Standard

Notes

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

No notes yet.