Flexible List Item / Branch Matching Python

Hi All,

Please note I recently started learning Python in grasshopper. With that being said, I haven’t been able to solve the following.

The goal is to find a match from list A to the item 0 of the branches in list B. “if” they match to create a new list. There might be 2 or more matches per item from list A and that is alright.

If there is a tutorial you suggest that I could follow I would really appreciate it or to please point me in the right direction.

Looking forward your support!

Flexible List Matching.gh (36.2 KB)

There are a lot of ways to approach this in Python.

The first issue is that you have a tree coming into the Y input. Trees are specific to Grasshopper, so it requires and additional set of methods. Here are the tree methods: Rhino - Grasshopper data trees and Python

It shows how to convert a tree into a list of lists and then methods to take a list back into a tree.

Perhaps that will give you enough hints as to how to insert the X list into a tree that is similiar.

Most of the examples and help for Python can be found here: Rhino - Rhino.Python Guides

1 Like

Thanks Scott! I appreciate it

This is a good article also: Handling Data Trees in Grasshopper Python Scripts | by Vincent Mai | Medium

1 Like