algorithmic modeling for Rhino
I took a stab at this. I am not sure it's the best way, but it seems to work. I dumped the following code into a GH Python component. Requires equal length input lists, (probably smarter to add some type of list length checking or something).
Outputs two lists.
List x = corresponding items from each list merged into one list item (actually outputting a list of tuples...more info here: https://docs.python.org/2/library/functions.html?highlight=zip#zip
List y = alternating items from each list combined into one list. (more info here: https://docs.python.org/2/library/itertools.html#itertools.chain
I never used these python methods, I just learned about them. I have absolutely no idea how efficient this is and what it would do with larger lists. But, it seems to be a basic python method for "weaving" two lists?
Need to change the inputs a and b to "List access"
import rhinoscriptsyntax as rs
import itertools
List1 = zip(a, b)
List2 = itertools.chain.from_iterable(List1)
x = list(List1)
y = list(List2)
All you need is Weave.
It puts together two lists in alternating fashion or according to a pattern, similar to an inverse of the Dispatch component.
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by