Blender Drivers how do you put in two if statements in a Driver Script Expression?

Driver scripted expression TWO if statements in ONE scripted expression.

Easy example of what I’m trying to achieve.

If Number >= 2 Number = 2 else Number(remains Number)
If Number <= 0 Number = 0 else Number(remains Number)

I’m wanting to scale a max and minimum through a scripted expression.

@Blender_Fun1

Is this legal? Helped me out last time.

yes, you can do it like this:

2 Likes

Thank you for the reply. cant believe you showed up. Much appreciated it.

But… Unless I’m reading this wrong.

the and statement seems to be giving me one final result. which is 1.

I need two end results. But I cant figure that out.

Unless there is an easier way to make a max and a min without using an if then statement.

Try this:
0 if (x<0) else (2 if (x>2) else x)

1 Like

max(z1,z2)

result:

dirver result


It’s maxing out with this set up. But it’s not registering once it hits lower than 1.

Hmm… That seems a little. Not sure if thats ideal.

Hold on. It’s not stopping it works. But It isn’t showing the Bone Scale. As I would scale it Up to 2.

It shows it going up. But it doesn’t show anything going down.

But numbers are fluctuating just fine.

Hmm maybe 0 and 2 are integer and you have to say 0.0 and 2.0 ← float

Alright its straight. It seems I forgot how my own rig worked.

I set it to 1 instead of 0. It’s great now.

Thanks guys.