Grasshopper

algorithmic modeling for Rhino

Hi all,

I  am facing a problem I cant handle myself now. I have a data tree in gh, the structure look like this:

You must have found that  a branch always contains a number the same as the path index .

now I want to combine some branches together ,the rule is : For path{2} contain number 2 and 5, then conbine the two paths together ,and for path{5} includes only 2&5,no other number ,so it's end .For path{3}, includes number 3&6 ,so we go to path{6}, path{6} includes 3&6&18, then wo go to path{18} , path{18} contains a new number 27, so we check path{27} ,path{27} includes only 27&18, no new numbers ,so it is end.


With this logic, path{2}&{5} become one tree finally , the contains is 2&5 ,and so path{3}&{6} &{18} &{27}(the contents is 3,6,18,27), and so others .


so what I want is:

{2}(2,5)+{5}(2,5)={2/5/anything}(2,5)         ## the new path index doesnot matter
{3}(3,6)+{6}(3,6,18)+{18}(18,27)+{27}(27,18)={3/6/18/27/?}(3,6,18,27)    
``````etc


I tried path mapper, but I donot think it can do the trick this time. may be I just miss something very visible?? Awaiting for your kind help~Thanks in advance.

Views: 431

Replies to This Discussion

Wow.



Just wow. This can be done, but it involves some pretty nifty accounting and looping. I don't see how it would be possible without a Script component.

I'll get cracking, see how far I get.

ps. It's only ever integers right?

--
David Rutten
david@mcneel.com
Poprad, Slovakia
Hi David, thanks for the so quick replay!!

Yes, only intergers.
See if the attached makes any sense.

--
David Rutten
david@mcneel.com
Poprad, Slovakia
Attachments:
Oh btw. the HarvestValues function is no longer used, I wrote it before I realized my first approach wasn't working.

--
David Rutten
david@mcneel.com
Poprad, Slovakia
Wow!! It's my turn to wow now!!

I think the script result is just what I need ! Thanks!!

What is HarvestValues function ?If you donot mind my blind to the script world and not very busy, just explain sth to me plz ! I find script is amazing and powerful now .

P.S. Just in curious ,it seems that a new version of GH will be released soon(the gh file leak this ,hah) ?
The Harvest function was supposed to recursively walk over the tree and collect all numbers that were 'reachable' from any given index. It didn't work because it could not travel in both directions. So it would create some incomplete lists which then gives problems down the line.

The script itself works roughly as follows:

For every branch+path in the tree it it will iterate over the entire tree again and again while collecting values from the data lists (but never the same one twice). If an entire iteration completes without growing the solution, I abort the infinite iteration and call it good.

Then I sort all index lists so that two lists that contain the same values also contain them in the same order.

Finally I remove all duplicate lists from the whole set.

--
David Rutten
david@mcneel.com
Poprad, Slovakia
Hi David,

I tried openning the file and got this message

error: '', hexadecimal value 0x04, is an invalid character. Line 1, position 1.

the file did not open, I'm using 0.07.0048

cheers

evert

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service