Grasshopper

algorithmic modeling for Rhino

Hello,

I am trying to generate a list of all possible combination of two trees of breps. I have two lists, and each branch in each list may contain 2-4 breps (which is why I cannot flatten them out):

List A:

{0;0} - contains breps A, B

{0;1} - contains breps C, D, E

{0;2} - contains breps F, G

List B:

{0;0} - contains breps H, I

{1;0} - contains breps J, K, L

and want to create a list all possible combinations:

{0;0}

{0;1}

{0;2}

{1;0}

{1;1}

{1;2}

or thinking in a matrix format:

I feel like this should be very simple but I am having trouble figuring it out! Any help would be appreciated.

Views: 899

Replies to This Discussion

...a list of all possible combination of two trees...

Combined in what ways?  I would suggest the following small change to your description, since to me, each branch is effectively a list as far as GH components are concerned:

I have two lists trees, and each branch in each list tree may contain 2-4 breps

I've never used the 'CrossRef' component before but maybe this is a good time?

Attachments:

But it's more complex than this, eh?  If you want all possible combinations using just one pair from each list (AH or BH or AI or BI), then there are 4 X 9 X 6 = 216 possibilities!?

Thanks Joseph,

I was thinking of something a little more simple (perhaps "all combinations" is worded too extremely). The total possible combinations in my first example would be 6. More clearly illustrated this is what the combination would look like:

I've managed to make the list by duplicating branches within each list and weaving them. It seems to me that there must be a simpler way, though. I did take your suggestion of looking into "CrossRef" but couldn't manage to work my way through it.

I've attached the GH file in case it is helpful for clarity and for others.

Would still be interested in hearing about a better way for next time!

Attachments:

Hi Mariana,
maybe this could qualify as 'a simpler way':

Pieter,

Yes! This is exactly what I was looking for. Thank you! That is perfect.

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service