Grasshopper

algorithmic modeling for Rhino

Could someone help me with how to flatten branches of a tree, but not the whole tree? So that for example {0;1;0}...{0;1;n} gets flattened down to {0;1} (N=n).

Views: 2117

Replies to This Discussion

Right now there is no component that does this, but it can be scripted. Check out the last posted definition in the following thread:
http://www.grasshopper3d.com/forum/topics/3dslicer-v11

I warn you, it's not an elegant solution at all, there's probably a better way to script it.
Would you mind pointing out were exactly in that definition you reordered the tree. That definition has a lot of stuff going on with it, so I'm just having a little trouble tracking down exactly were this happens. I didn't find any scripts within that definition, so I'm not convince when you say that it can be scripted. Not because one couldn't output the data tree, but rather because one can't get a data tree into a script component (it will end up as a flattened list).

I ran into this last week and was scratching my head as to how to get the tree "simplified", so I'm very interested in a solution for this. I think this should become a regular component in GH though.

Best,
Damien
Hi Damien,
I've attached the definition to this post, maybe you where looking at the wrong one. It's the only scripting component in the definition. Come on, it's not that big of a definition, specially compared to the first one of the thread.

I originally posted that method some time ago in the old forum, here:
http://groups.google.com/group/grasshopper3d/browse_thread/thread/3...
I did it rather quickly then and didn't bother to make a more decent solution so it's basically the same. It inputs the list flattened, as you say, together with the paths as 'strings'. It then gets the char from the string in the position that corresponds with desired path to be flattened and adds each element to that path.

It's not a generic solution at all, and breaks rather easily. In fact this version is slightly different to the one of the old forum since here i had a path within a path within a path.
Attachments:
Its been a few days, but I had finally had chance to take a look at this and that's a pretty novel way of doing it. I knew the trees would be flattened, so I was wondering how you would get the tree information back in and the strings/list lengths is a good solution, although somewhat tedious. Until David adds trees to the script inputs, if one is really set on maintaining tree structure that seams a darn good way to do so.

Funny thing is that now I can't find the definition that I really needed this for. Oh well, it will pop up sometime.
This will be available in the next build. I've written a simple wild-card system for matching branches. Unfortunately I don't know if I'll be able to release before my holiday starts.
This is a great script but I have the same problem with it that I did with the last one... because you are calling a substring of only one character length, this script only works with path structures within single digit groups. Paths 0;1 and 0;10 and 0;11 are all grouped together, which is why your eggcrate model script breaks down if your UV divisions are set to 11 or higher... I'm not sure the proper way to fix this, perhaps to pull the entire remaining string after position 6, then test for the ";" character and strip the rest of the string away based ont he results of this test?

Perhaps this will be moot if David postpones his vacation. :)

Marc
Heh, that's a serious flaw :) Thanks for pointing that out Marc. As i warned in this two threads, it hasn't been really tested at all. As you say, i think you should check for the next char and see if it's not ";". You could also investigate about the grasshopper path classes, maybe you can use that instead of reading them as strings.
Thanks a lot for the definition! However useless as I am at scripting and grasshopper would you mind having a look at my definition and see what is wrong? I added your script into my definition but what I hoped would come out as three (I have three initial curves) paths is coming out as one. Very grateful for any help!

Petra
Attachments:
i don't have rhino here but i'm guessing it's because all your paths start with 0. To avoid this, place a simplify tree component inbetween.
I have already put in a simplify tree component, so it shouldn't be that. Also the path that comes out after the script has N=1, which I think is a bit odd.
Hi, there's a couple of things you have to change. Open the script and substitute line 68 with this one:

Dim p As Integer = convert.ToInt32(y(i).substring(6, 1))

This will reset the script to the original from the old forum.
For some reason, I'm getting an error message that the points can't be added to the object list, i didn't have any problem with other types of objects. To fix this, you have to substitute line 65 with this one:

Dim tree As New DataTree(Of on3dpoint)

Btw, as Marc pointed out, this will only work if you are going to output 10 lists or less.

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