turn on/off translate limitation


#1

I did the rig with stretch. I created an attribute to turn on/of the stretch. But now when I am moving my leg down, all fingers controls move down too. I would like me not to can move leg and fingers controls below 0 of translate Y when my stretch is off.

How could I do it? How could I turn on/off the limitation of translate?


#2

Ok I’ve done a little python script that controls the transform limits for translate y.

import maya.cmds as cmds

def forAtrrChange():
theYVal = cmds.getAttr(“pCube1.ty”)
if theYVal >= 0:
cmds.transformLimits(“pCube1”, ety=(False, False))
else:
cmds.transformLimits(“pCube1”, ty=(-1 , 0), ety=(True, False))

cmds.scriptJob(attributeChange=[“pCube1.translate”, forAtrrChange])

The minimum value of the transform limit is activated when the translate y value is below zero. While this can show you how you can relate a certain event to the transform limits or any other transformation value, this script doesn’t add much functionality. You can get the same behavior by simply add the transform limit in the first place. See if you can adapt this script to your rig structure, by controlling the stretch attribute via the translate y or other factor.

If you want to get rid of the scriptJob just run the following line:
cmds.scriptJob(killAll=True, force=True)

All this script lines are made in Python so run them in the appropriate script editor tab.


#3

My previous post didn’t preserve the text indentation and this is important in Python scripting.
So I submit the same script as a picture in the attachment.


#4

Use code tags [ code ] and [ /code ] (without the spaces), and the text in between will be preserved properly and monospaced.


#5

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.