in Programmer by
Hi, I created an attributebutton with an Enum option, then added

IK

FK

and in the prechange I did setAttr("L_Leg_FK",0);

and in the post change, the opposite

setAttr("L_Leg_FK",1);

 

but it does not switch between 0 and 1.

can you help pls.

thankyou

1 Answer

0 votes
by

First, you don't need to manually set the attribute in the attribute button.

You can ask the attribute button to manage the attribute directly by setting its attribute:

The beauty of doing so is it will display the attribute value and sync with Maya, automatically. You don't need to worry about the namespace, or coding, etc.

If for some reason you cannot ask it to manage the attribute directly, in the command where you tried to set the attribute, you needed to count in the current namespace:

from maya import cmds
ns = cmds.MGPickerView(q=True, ns=True)
attr = "{}:L_Leg_FK".format(ns) if ns else "L_Leg_FK"
cmds.setAttr(attr, 1) 

It is python code but similar in MEL.

The video tutorial here might help: https://www.youtube.com/watch?v=hULSxdECKps

Categories

...