Announcements
Due to scheduled maintenance, the Autodesk Community will be inaccessible from 10:00PM PDT on Oct 16th for approximately 1 hour. We appreciate your patience during this time.
Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Retrieving useable line style

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
Anonymous
984 Views, 4 Replies

Retrieving useable line style

I was trying to retrieve useable line style(shown in combobox when we draw model or detail line) as typed below

 

FilteredElementCollector collector = new FilteredElementCollector(doc).OfClass(typeof(GraphicsStyle)).WhereElementIsNotElementType();

 

this code return so many graphicsstyle element.

 

i want to filter useable line style when draw line.

4 REPLIES 4
Message 2 of 5
Anonymous
in reply to: Anonymous

Hi,

 

After playing a bit with RevitLookup, I've found that you need to check the ParentCategory of the GraphicStyle. In you case it should be Lines.

2016-07-28_1858.png

 

Try the following code. I didn't check it myself, but should work:

            var styles = 
                new FilteredElementCollector(doc)
                .OfClass(typeof(GraphicsStyle))
                .WhereElementIsNotElementType()
                .ToElements()
                .Where(e=>e.Category!=null 
                    && e.Category.Parent!=null 
                    && e.Category.Parent.Id == new ElementId(BuiltInCategory.OST_Lines));

Thanks,

Victor.

Message 3 of 5
Anonymous
in reply to: Anonymous

i was trying to your code. but return 0 result.

 

i changed code.

 

Category => GraphicsStyleCategory 

 

var styles =
               new FilteredElementCollector(doc)
               .OfClass(typeof(GraphicsStyle))
               .WhereElementIsNotElementType()
               .ToElements().Cast<GraphicsStyle>().Where(e => e.GraphicsStyleCategory != null && e.GraphicsStyleCategory.Parent != null && e.GraphicsStyleCategory.Parent.Id.Equals(new ElementId(BuiltInCategory.OST_Lines))).ToList();

 

this code is working. but this result is not what is expected.

Message 4 of 5
Anonymous
in reply to: Anonymous
Message 5 of 5
Anonymous
in reply to: Anonymous

That's wierd, I just executed your code and it shows me exactly what you need.
I tried in Revit 2016.

Anyway, i glad you've found the solution.

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

Post to forums  

Rail Community


Autodesk Design & Make Report