Grasshopper

algorithmic modeling for Rhino

hi all,

 

i try to setup an expression like this: (Attach File)

if a < 500 then b, and if a between 500 and 600 then c, and if a>600 then d .

 

but i don't know the syntax which can handle this.

 

hope you can help me.

thx.

Views: 2453

Attachments:

Replies to This Discussion

Chris
Attachments:

If(A < 500, b, If(A > 600, d, c))

 

It's not very clean, but for a three-way split it's not too bad. This expression works as follows:

 

If(A < 500, b, If(A > 600, d, c))

 

If A is larger than 600, then the result of the bold part is equal to d, otherwise the result is equal to c. Let's call this result c|d, meaning it's either c or d, depending on the value of A. We can now rewrite the original expression and simplify it:

 

If(A < 500, b, c|d)

 

This is just a single If...Then construction where the Then part is the already partially solved result.

 

--

David Rutten

david@mcneel.com

Poprad, Slovakia

In the original post, "if a between 500 and 600 then c",  I can't decide if that should be taken as 'inclusive', ie. 500<=a<=600, or 'exclusive', ie. 500<a<600, of the end points.  I'm tending to think it generally means exclusive but the more I think about the less clear it becomes. 

 

Chris

thx,

 

that works fine :)

@chris: thx for the definition, i will try it also.

 

 

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