Grasshopper

algorithmic modeling for Rhino

Suppose we have a list of n items with values from 0-360 and we wanted to dispatch those items with value between 200 and 300. I have tried doing it all in a single step with a function with this expression:

If(x>A, 1, If(x<B, 1, 0))

and two sliders connected to the function, with slider A set to 200 and slider B set to 300. But what it does is output everything 1, because it changes the items with value less than 200 to 1, and then in the second if, well everything is smaller than 300.

Is there a way to apply multiple conditional statements in the function editor, as can be done in Excel? 

Views: 10523

Replies to This Discussion

You could use the [Find Domain] component with an [Equality] = 1 to get the dispatch list

And a humble one with evaluate component:

Attachments:

Thanks djordje (again)!

I didn't know you could add booleans to the expression editor. I did think about it, but I didn't see it in the expression editor's help so and didn't even try :s

It even works with several data paths. I think my days of combining multiple dispatches are over :)

Thanks Danny. I can't remember the last time I used the Find Domain component. It's a nice reminder. 

I did it beforehand with two dispatches, but I was hoping for something like what Djordje pointed out. 

Danny's knowledge exceeds far beyond yours and mine altogether.
So he was perfectly aware of the "if" statement usage in the Evaluate component.
He's intention was to created a solution with native grasshopper approach, with no programming connection. Which is quite logical, as grasshopper does not require programming knowledge.

Flattery gets you everywhere :)

You're right in the fact that I was going for the purist approach but I think Jesus was specifically referring to the AND Boolean operator that you included.

The Expression functions draw upon the VB functions so usually anything that works in VB will work here. You can see a good list in the Expressions Functions Menu from the Expressions Editor, but of cause AND OR etc don't feature there.

Ok, now where's that free boat you promised, for all the upper flattering?

:D

In my line of work its at the bottom of the sea :)

Yep AND, OR are not featured there, so I just assumed it couldn't be done. Assumptions the mother of all... 

Is the free boat the one on his avatar?

And yes, my programming skills are non-existent... for now. 

That's my beloved B14! http://www.grasshopper3d.com/video/b14-blur

Always up for sale / sail but never for free :)

Yes Jesus, that's the one :D

I arrive at Rhumsaa somewhere around 8 PM GMT. Will pick it up then.
:)

sale/sail :)


Ok got it. A Manx could sell his soul but never his boat :)

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service