Set joint attributes


#1

Hi all,

I’m trying to write a MEL script that will set all joints within a skeleton DOF to on and rotation limits to off. The lines to set them would be as below, but what I think I need to do is build an array to list all the joint names to put into the lines to set the attributes for all the joints in the skeleton. Any help appreciated.

$jointID[]
setAttr "$jointID.jointTypeX" 1;
setAttr "$jointID.jointTypeY" 1;
setAttr "$jointID.jointTypeZ" 1;
transformLimits -rx -360 360 -erx 0 0 $jointID;
transformLimits -ry -360 360 -ery 0 0 $jointID;
transformLimits -rz -360 360 -erz 0 0 $jointID;

#2

Better off in Python (select hierarchy first):

for node in cmds.ls(sl=True):
 	cmds.setAttr('%s.jointTypeX' % node, 1)
 	cmds.transformLimits(node, rx=(360, 360), erx=(0, 0))
 

If you have non-joints mixed in with your joints and it’s causing errors, you can add an ‘if cmds.nodeType(node) != ‘joint’: continue’ check to ignore non-joints.

The attribute spreadsheet can be quicker for simple changes than writing a script if you’re just going to do this once.


#3

Fantastic, thank you.


#4

OK, sadly this isn’t working. With the hierarchy selected the script runs without any error but doesn’t actually do anything. Have also tried with all joints selected and again nothing.

Scribbled a number of joints into the viewport and checked a few DOF to off and a few rotate limits on and after running the script, they’re all still as they were.

What I’m wanting is for the script to reset all the joints in the chain to be that their DOF are turned on (jointTypeX/jointTypeY/jointTypeZ set to 1) and the rotate limits are turned off (-erx/-ery/-erz 0 0)