Tree Utilities: Match Path and Partial Flatten

20Nov10

In the coming weeks, I am planning to release some clusters I’ve put together for use, and I thought I’d start with two that correspond to common operations I perform on data trees.

The first, Match Path, takes a flat list of data with N items, and another list of data with N items with some kind of arbitrary tree structure. The output is the first flat list, reconfigured to match the path structure of the input list. I was inspired to create this one by a post on the Grasshopper board by Arie-Willem de Jongh (here: http://www.grasshopper3d.com/forum/topics/apply-data-structure-to-a?page=1).

The second, Partial Flatten, takes a set of data with a tree structure and flattens the N lowermost levels of hierarchy. This has been requested a number of times as a built-in feature on the GH board – (see this thread for one example) but until it’s implemented this cluster will have to do.

Both tasks can be accomplished on an individual basis with the path mapper, but the problem with the path mapper in general is that changes to the data structure upstream require editing all downstream path mappers to get everything to work. The two clusters I am posting here avoid the use of path mappers entirely, so they will perform the same functions even if the structure upstream changes.

download both clusters here

Advertisements


3 Responses to “Tree Utilities: Match Path and Partial Flatten”

  1. Hi Andrew,

    I am trying to collect together an open-source library of Grasshopper components at parametricmodel.com. With your permission, I would love to add the two you have just posted. If you would like to discuss it further please email me (couldn’t find a contact page on your blog)

    Daniel


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: