Grasshopper

algorithmic modeling for Rhino

What's the elegant way of saying :

If "whatever" =True, then execute this part of the definition, but if it's =False, then execute this other part ?

I seem to be stuck with manual switching...

 

Cheers,

--

Olivier

Views: 8972

Replies to This Discussion

Chris

Hi Chris,

 

This is not what I mean.

I'm interested in what happens AFTER a "True" or "False" boolean has been evaluated.

To take your example, if x=1 (true), then I want to do a bunch of stuff, else I want to do a DIFFERENT bunch of stuff.

 

See ?

 

--

Olivier

One way is to use the Dispatch component with a single boolean value to activate different process streams. See the attached file for an example.
Attachments:

Exactly what I needed !

Thanks Andrew !

 

--

Olivier

another method is the stream filter gate on the sets section > tree tab. supply a 0 and only the input 0 goes through supply a 1 and only stream 1. there is alsp an input manager so you can add any number of inputs 0,1,2,3,....N

Thanks guys,

 

But what if I just want to trigger events without passing data to them.

Example : If n>10 then "draw a square", else "Draw a circle". With the "n" value having no influence whatsoever on the size or location of the said circle and square ?

 

I just need to trigger something ; not necessarily pass along some data...

 

Cheers,

 

--

Olivier

 

Hi Oliver,

This illustrates your example. When 'timeline' gets above 10 there will be a square instead of the circle.

In this case the 'data' to pass along is the geometry, and it doesn't actually have to go anywhere the filter is a preview enabled component.

Hi Danny, can I ask what expression you used in the domain, because I used my UserObject...
That was just -A so the domain is -10 to 10. Normally I have a domain component with expressions of -A/2 and B/2 so that I get the rectangle centred on the plane.

Of course the flip side to that is the Stream Gate, but this is passing the data onto another process.

Which process is up to you

Ah! Great, thanks! Another UserObject superfluous:)
(how come there's no reply button under your answer?~)

It's reached its limit in thread level, just like there's no reply for you now.

 

PS you can save the standard component with the expressions as a user component if you are going to regularly use it. 

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