Grasshopper

algorithmic modeling for Rhino

Dear All,

 

It is possible to sort path inside a tree?

 

Something like this:

tree.Path(i).Sort 

 

Thanks

Dimitry

Views: 431

Replies to This Discussion

Hi Dimitry,

 

and when you say "path" what exactly do you mean? You want to sort the numbers that make up the path indices, so that {0;0;1;0} becomes {0;0;0;1} ?

 

Or do you want to sort data inside the branches?

 

If the former, then no, paths aren't supposed to be mutable, meaning you're not supposed to change paths that are already part of a tree. You can create a new tree and supply paths that have been sorted.

 

--

David Rutten

david@mcneel.com

Barcelona, Spain

Hi David,

 

Thanks for the rush reply. 

 

I want to have an opportunity to sort data in tree branches, as it possible with lists or arrays, without to resave these.

 

something like this:

sort data in tree(path{0,0,n})

foreach (path in tree):

if  smth:

sort tree (path)

else: 

reverse tree (path)

 

Is that possible?

 

Best

D

There is no default comparer for data inside Trees, so you'll have to supply that. Are you doing this on GH_Structure(Of IGH_Goo) or DataTree(Of Object)?

 

And, can you say anything about the data inside the tree (what type, can there be nulls etc.)?

 

--

David Rutten

david@mcneel.com

Barcelona, Spain

was using DataTree(of double). but it could be int or point3d

 

Actually I already wrote a loop for saving a branch into a list and back, so no worries about that. If it will make sense please add function as sort or reverse, if not it is also ok.

 

Thanks

RSS

About

Translate

Search

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service