def zeroRotate(obj): ''' This method ge a pymel object as input and group it to zero its translation only @param: obj: PyNode, the object to zero out @return PyNode, the offset group ''' #get the parent par = obj.getParent() #create group name name = obj.name() temp = name.split("_") groupName = nameUtils.getUniqueName(temp[0],temp[1] + "Zero", "GRP") if not groupName: OpenMaya.MGlobal.displayError("Error:Name is not valid") return #create the a new transform node grp = pm.createNode("transform", n = groupName) #set the world matrix of the group grp.rotate.set(obj.rotate.get()) #rebuild the hierarchy obj.setParent(grp) if par: grp.setParent(par)
def zero(obj): #get parent object par = obj.getParent() #create group name name = obj.name() temp = name.split('_') #name = 'character_name' + side + '_' + basename + str(0) + '_' + suffix #charactername_r_wrist_0_loc # groupName = nameUtils.getUniqueName(temp[1], temp[2], 'grp') groupName = nameUtils.getUniqueName(temp[0], temp[1], 'grp') if not groupName: OpenMaya.MGlobal.displayError('Error generating name') return #create group grp = pm.createNode('transform', n =groupName) #set martix matrix = obj.wm.get() grp.setMatrix(matrix) #rebuild hierachy obj.setParent(grp) if par: grp.setParent(par) return grp
def createHook(baseName = 'hook',side = 'm',snapTo = None,inOut = 'in'): hookName = nameUtils.getUniqueName(side, baseName, 'HOOK') hookNode = pm.createNode('locator',n = hookName) hookNode = hookNode.getParent() hookNode.rename(hookName) digitType = 0 if inOut == 'out': digitType = 1 hookNode.addAttr('hookType',at = 'float',dv = digitType) hookNode.attr('hookType').lock(1) if snapTo: pm.xform(hookNode,ws = 1,matrix = snapTo.wm.get()) return hookNode