← Inbox

C3D-0559 · Read contour label styles 260711 R2 (read-only) done

Contour label style ids on the label groups (via reflection) and their text contents.

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

C# payload


var ms=(BlockTableRecord)Tx.GetObject(SymbolUtilityServices.GetBlockModelSpaceId(Db),OpenMode.ForRead);
var styles=new System.Collections.Generic.Dictionary<ObjectId,string>();
int ng=0;
foreach(ObjectId e in ms){ if(e.IsErased) continue; var o=Tx.GetObject(e,OpenMode.ForRead);
  if(o is Autodesk.Civil.DatabaseServices.SurfaceContourLabelGroup g){ ng++;
    foreach(var pi in g.GetType().GetProperties()){ if(pi.PropertyType==typeof(ObjectId) && pi.Name.Contains("Style")){ try{ var id=(ObjectId)pi.GetValue(g); if(!id.IsNull && !styles.ContainsKey(id)) styles[id]=pi.Name; }catch{} } } } }
Log("contour label groups="+ng);
foreach(var kv in styles){ var st=Tx.GetObject(kv.Key,OpenMode.ForRead) as Autodesk.Civil.DatabaseServices.Styles.LabelStyle; if(st==null) continue; Log("STYLE ("+kv.Value+") '"+st.Name+"'");
  foreach(ObjectId cid in st.GetComponents(Autodesk.Civil.DatabaseServices.Styles.LabelStyleComponentType.Text)){ var c=(Autodesk.Civil.DatabaseServices.Styles.LabelStyleTextComponent)Tx.GetObject(cid,OpenMode.ForRead); Log("   text comp '"+c.Name+"' contents="+c.Text.Contents.Value); } }
var cs=CivilDoc.Styles.LabelStyles.SurfaceLabelStyles.ContourLabelStyles;
foreach(ObjectId sid in cs){ var st=(Autodesk.Civil.DatabaseServices.Styles.LabelStyle)Tx.GetObject(sid,OpenMode.ForRead); Log("available: "+st.Name); }

Result

Status
success
Drawing file
C:\Users\sanja\OneDrive\_SurveyDisco\260711 - 281 Maranatha Trail, Lawrenceville, GA 30045, USA\260711 - 281 Maranatha Trail R2.dwg
Message
Executed C3D-0559 (0 entities touched).
Entities
—
Duration
578 ms
Civil 3D
25.0.0.0

Log

contour label groups=11
STYLE (UserContourLabelStyleId) 'Existing Major Labels'
   text comp 'Surface Elevation' contents=<[Surface Elevation(Uft|P2|RN|AP|Sn|OF)]>
STYLE (MinorContourLabelStyleId) 'Existing Minor Labels'
   text comp 'Surface Elevation' contents=<[Surface Elevation(Uft|P2|RN|AP|Sn|OF)]>
available: Proposed Major Labels
available: Proposed Labels by layer
available: Existing Minor Labels
available: Existing Labels by layer
available: Proposed Minor Labels
available: Existing Major Labels

Notes

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

No notes yet.