Grasshopper

algorithmic modeling for Rhino

I have forgotten how to achieve this natively within GH. 

I have a tree with x branches, each has 3 items that are all on path {0}. 

I wish to have {0}, {1}, {2}. Just adding to the hierarchy of the tree so it is divided into three sections. I have illustrated this for clarification. 

Thank you. 

Views: 3491

Attachments:

Replies to This Discussion

Hi Erik Sven, you can use path mapper: {A;B} -> {B\13;B}

No ... path mapper doesn't accept variables[13] (you'll need the Dark Side and GH_Lexer for that).

In the mean time get the Dark Side (where cookies are plenty and there's free warm Guinness for all).

Attachments:

And speaking about GH_Lexer ...

Attachments:

You can totally do it with path mapper as long as the value 13 is a constant.

If you want control over 13 via a slider you can do it using Replace Paths:

You can of course also do it with C#, but there's no need to scare people witless by using that as the go-to solution for any grasshopper problem.

Attachments:

C# it's just another alternative (and in the majority of cases I add the usual: "...although also easily doable with components ...  blah, blah" meaning that it's just ... another alternative, he he).

But strictly speaking ... indeed Erik asked for a component based solution, so I've added ... just another alternative.

best

Attachments:

@peter

I appreciate the response. I looked at the code and it sorta makes sense, but the other solutions certainly help. THanks!

@Pieter 

THanks for breaking down the path mapper. Such a powerful tool. 

Best, 

Erik

Thank you for your replies. This is one area that I always get tripped up on. I wonder if anyone can code this with Python. 

@Peter - I was going for the path mapper originally, but was using the pattern {A;B/13} which was obviously returning an error. If you can explain the structure of your pattern that would be helpful to my understanding of your approach. 

@David - I appreciate your native component solution. This is very helpful!

@the Dark Side. once again your approach works like a charm, but I am a novice python speaker and have yet to learn C#. Got a long way to go with python, but I hope to learn C# soon. 

Thank you again for your replies!

Erik

Erik

I know that you after the cookies (or the Guinness) he he: that's the reason for providing the 3 DS thingies.

Plan A: is the way to go: like David's native solution it deals with paths (branches) thus is the more "safe" approach. For instance Imagine branches with unequal N of items etc etc.

Plan B: Is the way that PM works ... but obviously {A;B} > {B\something} assumes that branches are equally populated: a recipe for Armageddon in other cases.

Plan C: Is equally "shallow" since getting a List out of a Tree and then doing the Skip/Take thingy assumes that ... see Plan B . Of course using FromList.ToList().GetRange(startIndex, nOfItems);

is the same kind of rabbit hole.

Native: See Plan C.

PS: Something/OtherSomething IS NOT the same animal with Something\OtherSomething not to mention that {A;B\Something} gives 2 dimensional (wrong) results.

PS: Some of your Lofted stuff is "weird"/twisted (check this, this and that he he).

PS: Notify if you want a pack of 66.66 "easy" C# examples about how to get a tree and make chaos or order or whatever comes first.

Moral: cold of warm Guinness? that's the 1M question.

best, The Lord of Darkness

Hi Erik Sven,
the trick was to use integer division, you can find all about it on the web.

I decided to ignore the other replies (except David's and Vicente's), simply because none of them produced the outcome you said you were after.
Also I'm not very fond of self-acclaimed deities (of whatever), especially if they tend to ramble about al sort of unrelated and non-sensical stuff, so I ignored that too.

I do share Vicente's concern about the need for this.

@pieter well put.

you can check the following two posts discussing similar topic.

post1

post2

the second post is from the treesloth plugin group. check out David Stasiuk's solution. maybe partition tree could be a component in a future release.

best

alex

What is the exact reason you want to do this for? Not always, but having to modify the tree structure in this way is usually a symptom of a problem that could be fixed by refactoring the definition leading up to this point.

I guess the components you used here are just an example, but the obvious solution would be to divide the loft output in 3 branches (using partition list, for example) before using the Deconstruct Brep component.

Doh, I hoped to be the first person to use the term "refactoring" referring to a Grasshopper definition. Unfortunately, I found one other comment from 2011.

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