← Inbox

C3D-0444 · Copy 3 parcel curve label styles into 260711 [C3D-0443] error

Side-open SS_BLOCK_11X17.dwg; WblockClone parcel CURVE label styles DELTA OFF, Delta over Length and Radius, Standard into 260711 using the destination collection owner id.

Script file
C3D-0444.cs
Target
260711 - 281 Maranatha Trail.dwg · model space
Author
claude
Approved
yes · auto-auth
Timeout
60s

C# payload


string path = @"C:\Users\sanja\OneDrive\_SurveyDisco\SS_BLOCK_11X17.dwg";
var want = new System.Collections.Generic.HashSet<string>(StringComparer.OrdinalIgnoreCase){"DELTA OFF","Delta over Length and Radius","Standard"};

// destination owner id: the OwnerId of an existing curve label style in the CURRENT dwg
ObjectId destOwner = ObjectId.Null;
var dcs = CivilDoc.Styles.LabelStyles.ParcelLabelStyles.CurveLabelStyles;
foreach (ObjectId did in dcs) { var ds=(Autodesk.AutoCAD.DatabaseServices.DBObject)Tx.GetObject(did,OpenMode.ForRead); destOwner=ds.OwnerId; break; }
Log("destOwner null? " + destOwner.IsNull);

using (var sideDb = new Database(false, true)) {
    sideDb.ReadDwgFile(path, System.IO.FileShare.Read, true, null);
    var ids = new ObjectIdCollection();
    using (var stx = sideDb.TransactionManager.StartTransaction()) {
        var cd = Autodesk.Civil.ApplicationServices.CivilDocument.GetCivilDocument(sideDb);
        foreach (ObjectId sid in cd.Styles.LabelStyles.ParcelLabelStyles.CurveLabelStyles) {
            var s=(Autodesk.Civil.DatabaseServices.Styles.LabelStyle)stx.GetObject(sid,OpenMode.ForRead);
            if (want.Contains(s.Name)) { ids.Add(sid); Log("queued: "+s.Name); }
        }
        stx.Commit();
    }
    if (ids.Count>0 && !destOwner.IsNull) {
        var map = new IdMapping();
        Db.WblockCloneObjects(ids, destOwner, map, DuplicateRecordCloning.Replace, false);
        Log("cloned "+ids.Count+" styles");
    } else Log("blocked: ids="+ids.Count+" destOwnerNull="+destOwner.IsNull);
}
Ed.Regen();

Result

Status
error
Drawing file
C:\Users\sanja\OneDrive\_SurveyDisco\260711 - 281 Maranatha Trail, Lawrenceville, GA 30045, USA\260711 - 281 Maranatha Trail R2.dwg
Message
eInvalidOwnerObject
Entities
Duration
415 ms
Civil 3D
25.0.0.0

Log

destOwner null? False
queued: DELTA OFF
queued: Delta over Length and Radius
queued: Standard

Notes

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

No notes yet.