Grasshopper

algorithmic modeling for Rhino

I want to combine several data trees into one, with a branch for each

Like Entwine, but without flattening (I want each branch to maintain its original tree structure).

It seems like there should be a straightforward way to do this for the general case, but I can't seem to find it.

Views: 7527

Replies to This Discussion

can you post your def?  I'd probably use the replace branches component for each stream of data to add lead ins and then merge the data sets.

Sorry, maybe I should have emphasized "straightforward" and "general case".

Of course it can be done with several components, and I found a few solutions on the forum (mostly involving replace branches and merging as you suggested). It just seems odd to me that it's so involved and effectively has to be customized for each case, depending on how many trees are involved.

Really I guess I just want entwine without flatten :-)

In my case, this would just be a convenience to keep total component count down: for example in one definition I have a spot where 6 trees all go through CleanTree components in "parallel", I'd rather just use one CleanTree, if it were easy to combine then decompose the separate trees.

This kind of situation seems to come up regularly for me, and I'm always striving to keep the component count low and things tidy in my definitions, for easy maintenance and future-proofing.

wouldn't u just graft entwine output?

Thanks, but the structure of the original trees isn't preserved that way. (It works fine if and only if the original trees are "flat" with only 1 item per branch.)

post your file, it will make this process much easier than guessing :)

My file is way too involved to demonstrate this simple idea. And besides, it's irrelevant.

I simply want to take ANY collection of data trees, with ANY structure, and make a new, single tree that has a separate branch for each of those trees, preserving all the original structure. 

(By the way, let me say that what started as a casual wish is now assuming more weight and verbage than it probably deserves...but I'll keep soldiering on! :-)

Here's an example:

Tree 1 (3 branches)

{0;0;0} 2 items

{0;0;1} 3 items

{0;0;2} 1 item

Tree 2 (2 branches):

{0;0} 1 item

{0;1} 5 items

Combine to make a single tree like this:

{0;0;0;0} 2 items

{0;0;0;1} 3 items

{0;0;0;2} 1 item

{1;0;0} 1 item

{1;0;1} 5 items

So the first tree is at branch {0...}, and the second at branch {1...}. If I were to separate those 2 branches and strip off the first number, I'm back where I started.

I hope that's clear...but either way don't worry about it too much :-) I really was just sort of wishing out loud, and wondering why such an obvious operation (at least to me) wasn't simple to accomplish.

Thanks for taking a look in the first place!

using varied lists still for me with grafting entwine gives each tree with the separate branches as you wish however it always matches what ever the longest structure is, this is how.9 matches data see here

I'm confused: doesn't Entwine always flatten the inputs? So for instance, Tree 1 above gets flattened into a simple list of 6 items. Nothing you do after that can restore its structure...

Unless it's different in 9.x...I'm still on 8 because I'm using a lot of legacy definitions.

I don't think this is possible for an arbitrary number of trees without scripting. Even with scripting you need some pretty nasty hacks (see attached).

--

David Rutten

david@mcneel.com

Poprad, Slovakia

Attachments:

Yeesh...let's leave the hacks out of it.

Earlier today I started scripting something, mostly as an exercise, and I just had a separate input for each tree (limiting the number of trees, of course...so much for the "general case"). That doesn't require hacks, right? I can just prepend as needed and traverse the input trees to copy them. But I didn't get far before some real work intervened :-)

At this point I don't think it's important enough to spend time on, but thanks, all, for taking an interest!

David,

This is a fantastic resource, thanks. I'm working on a couple of clusters where ideally I'd be able to run this script you've posted within the cluster itself. However, being connected to the cluster input, the script only recognizes the data as coming from one source. Is it possible to augment this method to prepend trees based on the number of connections to the cluster input?

Thanks in advance,

Grant

Attachments:

Well...here's a way that, while still inelegant in that you have run each branch through, it may streamline your process a bit.  I have the same issue often...I wrote a little vb script to extract a variety of data elements from a data tree to assist in remapping various bits of geometry.  This script drives the info for a replace branch component and adds a lead value of your choice to the data path.  You could cluster it easily.

I've included some incredibly dumb surfaces for reference geometry.

Attachments:

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