Change Linestyle to Linestyle Not Yet Used In Project

Hi,

I’m attempting to create some model lines with Dynamo and then change the linestyle of them to a linestyle that hasn’t been used within the project.

Normally I’d simply select all lines in the project and then filter to find the GraphicsStyle I need and SetParameterByName on the new lines but as I have not yet drawn a line of that style I need a different way (I am aware I could just draw the lines somewhere but I’d like to know if it’s possible to do so without).

I can get_Item(BuiltInCategory.OST_Lines) and then find the SubCategories but then I end up with Categories rather than Elements even though the list of SubCategories and GraphicsStyles technically matches up.

I had thought that I could find GraphicStyle.Name that matches the Category.Name and apply that GraphicStyle but I don’t know how to do that and it all feels like there should be a much simpler way (I’m only just fumbling my way around Python at the moment).

Any help appreciated, thank you!

Not sure if your solution has to be in Python, if not Bimorph Nodes contains nodes to create Line Patterns and Styles. Based on the internal python code it looks to possibly have originated in GeniusLoci and migrated here…

You could build a script to check if a line style exists, run through an if node and generate a line pattern, wait/passthrough then use this pattern in a new line style creation node.

The Python scripts are accessible for the Line Pattern node but not Line Styles - might be worth contacting Bimorph or GeniusLoci package creators.

BM%20nodes