Is there a way to determine if a specific Style object is in-use?

By Partha Sarkar

In Civil 3D
UI, if we expand the styles collection of a Civil 3D object, you will notice
the yellow triangle next to it which indicates this style is 'in-use', e.g. in
the screenshot we see the style collection of Surface styles which are in use –

Styles_01

 

In Civil 3D
2014 .NET API, we have a very useful API StyleBase.IsUsed which will tell us if
a particular style is in-use.  Here is a
relevant C# code snippet :

 

foreach (ObjectId surfaceStyleId in civilDoc.Styles.SurfaceStyles)
{
  //  Open each style object to check if it is "in-use"  
 
  SurfaceStyle csStyle = surfaceStyleId.GetObject(OpenMode.ForRead) as SurfaceStyle;
  if (csStyle.IsUsed)
    surfaceStyleNameColl = surfaceStyleNameColl + "n " + csStyle.Name.ToString();
}

Comments

Leave a Reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading