You probably don't want to toggle the keyable status... What if the
animator has keys on that attr?  I don't know off the top of my head if
Maya would keep those keys or not.
 On Nov 26, 2012 11:11 AM, "Justin Israel" <[email protected]> wrote:

> I feel like an expression may not be the best spot for this functionality.
> Wouldn't that imply that it would only get evaluated when the time changes
> or the node is dirty? It seems to me what you want is a trigger that reacts
> to actually changing your "fkik" setting.
>
> A script job probably suits the situation better:
>
> ##
> def toggleStuff():
>     val = cmds.getAttr('legCtrl1.fkik')
>     if val == 0:
>         cmds.setAttr('legCtrl1.tx', k=False)
>     elif val == 1:
>         cmds.setAttr('legCtrl1.tx', k=True)
>
> jobId = cmds.scriptJob(attributeChange=['legCtrl1.fkik', toggleStuff])
> ##
>
> This will immediately react to the change of your fkik attribute, and run
> a python function that can check and change your attributes.
>
> -- justin
>
>
>
> On Nov 25, 2012, at 6:27 PM, Berg Jones wrote:
>
> I have one control that I'm using to control FK/IK on a leg. I dont want
> to have one for IK and one for FK because it gets confusing. Right now I
> have reverse foot roll and translate attributes that I want to hide when
> I'm in FK mode and vice versa.
>
> Heres the expression in question that will  disable translateX but wont
> unhide switch into IK.
>
> Thanks!!!!
>
> import maya.cmds as cmds
> import maya.mel as mel
>
> mel.eval('proc hideStuff(){setAttr -k 0 "legCtrl1.tx";}')
> mel.eval('proc showStuff(){setAttr -k 1 "legCtrl1.tx";}')
>
> myExpr = '''
> if (legCtrl1.fkik == 0)
> {
>     hideStuff();
> }
>
> else if (legCtrl1.fkik == 1)
> {
>     showStuff();
> }
> '''
>
> cmds.expression(string=myExpr)
>
> --
> view archives: http://groups.google.com/group/python_inside_maya
> change your subscription settings:
> http://groups.google.com/group/python_inside_maya/subscribe
>
>
>  --
> view archives: http://groups.google.com/group/python_inside_maya
> change your subscription settings:
> http://groups.google.com/group/python_inside_maya/subscribe
>

-- 
view archives: http://groups.google.com/group/python_inside_maya
change your subscription settings: 
http://groups.google.com/group/python_inside_maya/subscribe

Reply via email to