Community
Civil 3D Customization
Welcome to Autodesk’s AutoCAD Civil 3D Forums. Share your knowledge, ask questions, and explore popular AutoCAD Civil 3D Customization topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Profile Style Collection C#

1 REPLY 1
SOLVED
Reply
Message 1 of 2
Anonymous
766 Views, 1 Reply

Profile Style Collection C#

Is there any way to get profile styles in the current dwg.

I want to list the styles.

ObjectId styleId = doc.Styles.ProfileStyles[0];
ObjectId labelSetId = doc.Styles.LabelSetStyles.ProfileLabelSetStyles[0];

Above code only gets 1st style.

Is there any way same like this below?

oAlignments = doc.GetAlignmentIds();

 

1 REPLY 1
Message 2 of 2
Jeff_M
in reply to: Anonymous

This is an extension method to get the names of any StyleCollection:

 

        public static List<string> StyleCollectionNames(this StyleCollectionBase scb)
        {
            var list = new List<string>();
            foreach(ObjectId id in scb)
            {
                var style = (StyleBase)id.Open(OpenMode.ForRead);
                list.Add(style.Name);
                style.Close();
            }
            return list;
        }

 

 

and sample usage:

 

        var stylelist = CivilApplication.ActiveDocument.Styles.ProfileStyles.StyleCollectionNames();
        Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage("\nThe first name in the list is {0}", stylelist[0]);
        var setslist = CivilApplication.ActiveDocument.Styles.LabelSetStyles.ProfileLabelSetStyles.StyleCollectionNames();
        Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage("\nThe first name in the list is {0}", setslist[0]);

 

Jeff_M, also a frequent Swamper
EESignature

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Rail Community


Autodesk Design & Make Report