Python errors in example scripts

Python errors in example scripts

cmiddlin
Enthusiast Enthusiast
875 Views
2 Replies
Message 1 of 3

Python errors in example scripts

cmiddlin
Enthusiast
Enthusiast

I’ve managed to add some hands in that we rigged in Maya and have outputted a number of steps as the hand open and close.

I’ve created animations using clips in vred which I can trigger on and off , but what I’ve been trying to do is make it so as you press the front trigger it the hands open and close depending on how far you push the trigger in and out.

 

In the test script it outputs a value between 0-1 and prints the value , I’m no expert when it comes to the scripting and I spent a few hours yesterday trying to get this working so I’m hoping you can save me a lot of time and syntax errors lol.

 

Can you show me how it should be scripted

 

I’m basically looking for something that says

 

If value is >0 and <.1 run variant 1

If value is >.1 and <.2 run variant 2

If value is >.2 and less than <.3 run variant 3

Etc .

 

I know it sounds basic but as I said after a few hours of seeing syntax errors I got frustrated and gave up and thought it best I just ask the experts for help.

0 Likes
Accepted solutions (2)
876 Views
2 Replies
Replies (2)
Message 2 of 3

dlincol1
Advocate
Advocate
Accepted solution

Hi cmiddlin,

 

I have run into similar situations and this is one way to do it...

 

# Define a function

def convertTriggerVal(triggerVal):

         # Round trigger value to 1 decimal place
    rndTriggerVal = round(triggerVal, 1)
    print triggerVal, rndTriggerVal

 

         # run variantSet position_0.1,  position_0.2, etc
    selectVariantSet('position_' +str(rndTriggerVal))

 

 

if value > 0.0:

         # Call function
    convertTriggerVal(value)

 

 

Regards,
Dan
Message 3 of 3

cmiddlin
Enthusiast
Enthusiast
Accepted solution

Thanks Dan , perfect 🙂

0 Likes