I'm busy creating a function in my rigging tool which allows mirroring of joints and replacing the prefix. The mirroring of joints (both behaviours and orientation) is working but I get an error when I search and replace
what is in my two text fields. The prefix of joints in the scene is either R_
or L_
and I would like to replace them with this.
The error is as follows: NameError: name searchFor
is not defined. The odd part here is that I actually create a variable called searchFor
and one called replaceWith
. See the code below:
import maya.cmds as cmds
child2 = cmds.gridLayout( cw = self.size[ 0 ] / 2 - 10, nc = 2 )
cmds.text( l = ' Mirror Joints', al = 'left', font = "boldLabelFont" )
cmds.separator( style = 'none' )
searchFor = cmds.textFieldGrp( tx = 'Search for...' )
replaceWith = cmds.textFieldGrp( tx = 'Replace with...' )
cmds.button( label = 'Mirror Orientation',
command = "cmds.mirrorJoint( cmds.ls( sl = True ),
mirrorYZ = True,
mirrorBehavior = False,
searchReplace = cmds.textFieldGrp( searchFor, q = True, tx = True),
cmds.textFieldGrp( replaceWith, q = True, tx = True )" )
cmds.button( label = 'Mirror Behaviour',
command = "cmds.mirrorJoint( cmds.ls ( sl = True ),
mirrorYZ = True,
mirrorBehavior = True )" )
The code is part of the UI as where the other functions are called forth from another module. Can it be that I need to create a function which includes the mirrorJoint
command in the UI module? Or is this a viable approach?
For a better view of the code: https://dl.dropboxusercontent.com/u/545575/python.zip