Grasshopper

algorithmic modeling for Rhino

Hi guys,

how can I put following if statement in gh in one component?

If x < y then x = y, If x > y then x = y

I don't understand how to put it in one VB component.

Can anyone help me?

 

Thanks, Tanja

Views: 884

Replies to This Discussion

Hi Tanja,

Do you want to use both statements in the same component? This would not make sense because it would actually be the same as replacing x with y (there is no if statement in that).

If it is two different examples then there is the minimum and maximum components which do exactly that. You can find them under math->utilities tab.

cheers, nikos

Sorry I have written something wrong. My fault.

I want this in one component:

 

If x<y then use y , if x>y then use x 

Hi Tanja, did I understand correctly? :

but Pieter, what would be the point of such an operation? The result of it is that in any case x becomes equal to y so why not just replace it?

anyway, hopefully Tanja will pop in and explain what she wants.

I can only guess at what Tanja's reason(s) is/are, but this does replace the x, doesn't it? There's more than one way to achieve this, as Arend just pointed out. His functions indeed are smarter - the dedicated functions for this operation, I just didn't recognize them right away~ doh!

it is actually two different things, 

one is using the two statements together (which actually always turns X into Y)

and the other is using the one statement or the other (which can be achieved with the min or max component as Arend and I stated.)

I'd say the y becomes x, but then again I'm a bit crossed eyed this week I guess ~ your answers about (Math.)Max are best. Thanks guys.
In VB component, as requested:
A = New Point3d(Math.Max(P.x, P.y), P.y, P.z)
Please don't tell me I messed this up too~ haha

Seems like the Min command to me.

x= Math.Min(x,y), always takes the smallest of the two.

or x = Math.Max(x,y) always takes the largest.

Or the minimum command in grasshopper.

I am not sure these two statements are meant to be together. this seems like a general how to question

but again this is only a speculation.

Let's say x is 5 and y is 8, Math.Min(x,y) will return 5.

Math.Max(x,y) will return 8.

(Is my speculation, since Tanja's if-then statements are rather weird, no matter what the case, x=y. You could say we don't need x at all, right?)

This uses VB script. It's literally the only thing I can do with VB.

Attachments:

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service