Grasshopper

algorithmic modeling for Rhino

Data tree operations (also a small series of questions)

Hello,

I was wondering if there are operations on datatree as I encontered some difficulties (maybe these are dumb questions):

1) first, let's consider a datatree with 3 branches with 2 components:

It could look like this in a panel

{0}
0 - A
1 - B
{1}
0 - C
1 - D
{2}
0 - E
1 - F

question: can you operate on elements between branches?
By default, when you apply polyline, it will connect the elements inside their branch. But how do we connect '{0} 0 - A' with '{1} 0 - B' and '{2} 0 - C'?

2)If we have 6 elements (A,B,C,D,E,F) at the same level or issued from a flatten operation, how do we create a tree like this one:

{0}
0 - A
1 - B
{1}
0 - C
1 - D
{2}
0 - E
1 - F

?

3) a work around would be to reverse the branch:

as the following transformation:

from this list:

{0}
0 - A
1 - B
{1}
0 - C
1 - D
{2}
0 - E
1 - F

that would transform in this one

{0}
0 - A
1 - C
2 - E
{1}
0 - B
1 - D
2 - F

?

4) Can we do such operation:

from this list:

{0;0}
0 - A
{0;1}
0 - B
{1;0}
0 - C
{1;1}
0 - D
{2;0}
0 - E
{2;1}
0 - F

to

{0}
0 - A
1 - B
{1}
0 - C
1 - D
{2}
0 - E
1 - F

5) I saw in a previous discussion in the VB# corner (about grid) that David was suggesting using some methods but I don't know how to use the "GH_Path" and the "Grasshopper.DataTree" object? is there other methods which are not mention either in SDK doc and Primer Grasshopper hand book?

Many thanks

Views: 2842

Replies to This Discussion

Having not read all your post, I may say that everything you are asking for is very possible, and quite easy to achieve.

Chech the GH Primer second Edition, there's a chapter about data trees. Playing with data can be really fun with GH, at least I feel really confortable playing with it. Its pretty easy and very intuitive. Practice a little bit, and everything will look much more clear.

1- You can use a List Item and call for 0, 1 and 2. Then you will have three lists with all data in positions, 0,1 and 2.

2- I would use a cull pattern maybe

3- I think is the same question than the first one, the answer would be the same

4- The last will be very usefull to use a Path Mapper component with this mask {A;B} as input and {A} as output.

Hope it helps, I'm sure there's better ways of doing it, but this could be a fast solution.

Cheers
Thanks Pep, I'll apreciate your answer

I did read part of the GH primer. The chapter on data trees is good but doesn't have what I need.

1) The List Item will work for a small amount of element.

But in case of points resulting of a grid 60*40 it is different and also it won't be parametric.

(I made my examples simpler than my need)

So my question is still not solve.

2) The cull pattern is to destroy some branch or element. In my question it was more how to build a tree controling the number of branch and the number of element by branch

Any clue?

3) this question is more about how to reorganise branch of a tree like you would do for a matrix
but as you suggested I solved this one with the path mapper


4) for this one it works fine

So this 'path mapper' is really an amazing tool, that's great (I just downloaded the gold version)

Anyway the 2 last questions are solved but I feel like the 2 first questions could be push further more. But the reply was a good help.

Cheers
I know... but you should not scare the form with such long questions, lol. I'm kidding, is good to ask.

About what's left un-answered... You are right, in a big matrix the fast solution I xplained won't work. But combinig path mapper and graft component, I'm sure you will find a way.

And if anybody here have a better solution, please let me know :)


Good luck
Hi!

i realized that you were trying to find out the "data tree" structure stuff. the first and the second questions could be done with series obj. and list item obj. (also list tree obj.) but i m also trying to find out your 3. and 4. questions. i think for creating new branch systems (especially like you mentioned at the third one) "replace branches obj." could be used.

the problem is i could not find the right way to use this obj.

besides that i cant find any post-beginner tutorial that shows those objects and stuff.

were you able to find any solutions of your questions via tree objects or other ways?

thanks,

And maybe one more question, if Icould:

What if I wanted to flip data in the whole tree? So that every list gets reversed and the order (names) of branches too... It would look like this:

{0}
0 - F
1 - E
{1}
0 - D
1 - C
{2}
0 - B
1 - A

Hi Simon,

you could flatten the tree, then reverse the list, then you unflatten the tree. As the Guide tree in "Unflatten" you use the initial tree, before you flattened it.
That should do the job.

Benjamin

Hi,

you can also use path mapper by writing source will be {A;B} target will be {A;3-B}

Note : 3 is the number of branches...

Ahmed

Hello,

I'm curious if you figure out how to do this:

2)If we have 6 elements (A,B,C,D,E,F) at the same level or issued from a flatten operation, how do we create a tree like this one:

{0}
0 - A
1 - B
{1}
0 - C
1 - D
{2}
0 - E
1 - F

If so, would you mind sharing your answer? I'm trying to do the same...Thanks

Hi,

you can also use path mapper by writing source will be {A;B} target will be {A;3-B}

Note : 3 is the number of branches...

Ahmed

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service