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.
Solved! Go to Solution.
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.
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.
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.
sovled.
i refered to link (http://adndevblog.typepad.com/aec/2015/03/revitapi-how-to-get-line-style-names-only-for-creating-det...) and (http://thebuildingcoder.typepad.com/blog/2008/11/model-line-creation.html)
i used method GetLineStyleIds();
Can't find what you're looking for? Ask the community or share your knowledge.