Line Patterns In Use

Line Patterns In Use

Dale.Bartlett
Collaborator Collaborator
1,498 Views
3 Replies
Message 1 of 4

Line Patterns In Use

Dale.Bartlett
Collaborator
Collaborator
Is there a way to list all Line Patterns that are referenced (used) by some element or even a Line Style? Dale



______________
Yes, I'm Satoshi.
0 Likes
1,499 Views
3 Replies
Replies (3)
Message 2 of 4

zhong_wu
Autodesk Support
Autodesk Support

It’s possible to get the line pattern from Line style.

 

Actually, Revit API does not provide a true 'Line style' element, the line styles are actually subcategories of the Lines category. Since Revit 2017, developer can get/set the relationship between Line Style and line pattern by methods as follow:

 

public ElementId Category.GetLinePatternId(GraphicsStyleType graphicsStyleType)

public void SetLinePatternId(ElementId linePatternId, GraphicsStyleType graphicsStyleType)

 

To list the line pattern used in a line style, you can get the Lines category,

 

Categories categories = doc.Settings.Categories;
Category lineCat = categories.get_Item( BuiltInCategory.OST_Lines );

 

then iterate all the subcategories of the lineCat, and call Category.GetLinePatternId() method as shown above to get the line pattern element.

 

That’s the way to get line pattern from line style, but what do you exact want to get the line pattern from element? It’s not feasible without any detail background.

 

Btw, there are 2 nice blogs for your to reference if you are interested:

http://thebuildingcoder.typepad.com/blog/2016/10/how-to-create-a-new-line-style.html#6  

http://thebuildingcoder.typepad.com/blog/2013/08/retrieving-all-available-line-styles.html

 

Hope it helps.


John Wu
Developer Technical Services
Autodesk Developer Network


0 Likes
Message 3 of 4

Dale.Bartlett
Collaborator
Collaborator

John,

Thanks for the reply, and that will be helpful.

My reason for asking is that I want to determine whether a particular Line Pattern is referenced.

For example, either by a Line Style (which may or may not be used/referenced), or by an Object Style. Notably, an Object Style will reference a Line Pattern directly as it does not use a Line Style. So aside from your examples which will let me find Line Patterns referenced in Lines>Line Styles>Line Patterns, there is also the case of Object Styles.

Dale




______________
Yes, I'm Satoshi.
0 Likes
Message 4 of 4

zhong_wu
Autodesk Support
Autodesk Support

Hi Dale,

Object Style should be similar, it should also be represented by category, you can iterate all the categories to check the line pattern with the same method as I suggested above. Please give a try and let me know if any further questions. 


John Wu
Developer Technical Services
Autodesk Developer Network


0 Likes