Grasshopper

algorithmic modeling for Rhino

I am posting here again, since the bug report is still unanswered, maybe someone has a workaround.

So I am merging 2 data streams with different path depths, like {0},{1},{2} and {0;0;0}, {0;0;1},{0;0;2}. So when I simplify all the inputs to merge, it does what is expected and bundles everything together into the {0},{1} and {2} lists.

But now the patch can also produce just single branches, so one in the format {0} and one in the format {0;0;0}. Simplify does nothing to those paths and therefore merge results in two branches.

Anyone have a workaround for simplifying single data streams (but not flattening). I know I can just check the number of branches and then switch to a different merge that flattens the inputs, but I would rather use just a single node which accomplishes this. To be honest, I dont understand why simplify ignores single branches.

Here is another example.

2 branches:

1 branch:

Views: 2063

Replies to This Discussion

Not completely sure what you are after, but my best guess is that you'll want to use Entwine (with in its context menu Flatten Inputs enabled) instead of Merge component. Optionally simplify its output.

I am after a component, which will simplify the path of a single branch, the same way it does for multiple branches.

If I have 2 branches, say {0;0;0} and {0;0;1} and simplify them, it will result in {0} and {1}. But if I try to simplify 2 flat branches with, say {0;0;0} and {0;0}, then it does NOT result in a single simplified {0} branch, as you might expect, but in 2 branches with the exact same paths as before.

I just need something that works in both cases, as only flatten will do the desired result for single branches. But I want the branches to be separate for the logic of the script, so flattening is not an option. The number of branches can change from 1 to any number. Everything works fine for multiple branches, but as soon as I am trying to merge and simplify 2 single branches with different paths, it breaks the script, because simplify does not simplify single branches.

Seems like I will have to check for the number of branches and redirect to 2 different merge components, one where the inputs are flattened for single branches and one where the inputs are simplified for anything with more than 1 branch.

I am just baffeled why simplify would not work on a single branch. Seems odd and like a bug to me.

Simplify's logic requires paths of identical length because it relies on direct mapping of path indices for its testing. The issue I think has to do with "what ifs" that come up based on various combinations. For example, what do you simplify in this case: {0;0} {0;1} {1;0} {0} {1}? Simplify is just being very conservative.


This is an annoying problem, though...here I've attached a script which should help you address your issue, and it gives you a couple of options. It either "truncates" a tree by removing indices from the right until the overall structure matches the number of indices in the simplest path, or "expands" a tree by adding zero-based indices to simpler paths until their overall structure matches the number of indices in the most complex path.

I'll encode this in Treesloth for the next release, for sure!

edit: the first one I posted had a small error...

fixed...

Attachments:

Thank you so much, it works as expected with your truncate+expand component! :) 

Multiple branches:

Single branches:

btw I realize that I didn't adjust the code in the second component (the one set to "truncate" in the def...anyone using this file please delete the second one and just use the first.

Thanks for the Explanation. So it seems that simplify might not do anything on a single branch, because it fails to check against another branch wether or not the path length is identical and then just doesn't do anything, rather than actually reducing the path length to the shortest possible length, ie. {0}.

Will try the script in a second, but looks promising :)

ps: I'm using treesloth already ;)

That's exactly right...a DataTree with a single path of {0;0;0} will simplify to {0;0;0}, but one with two of {0;0;0} and {0;0;1} will simplify to {0} {1}.

Here is a file, which hopefully demonstrates the problem.

Attachments:

You can use PathMapper as an alternative, or maybe Principal for some parameter in previous components.

This seems to be the only way to get what I want, which is not ideal, because its unecessarily complex.

Attachments:

So you want to duplicate the first branch? What's the objection against flattening? I'm sorry I just don't understand the what and why here.  Maybe what David just said helps?

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