def multiplyNode(name='multiplyDivide'): '''Create a multiply node''' node = cmds.shadingNode('multiplyDivide', name=name, asUtility=True) node_name = util.nameReformat(node) cmds.setAttr('{0}.input2X'.format(node_name), 2) return node_name
def tempMove(prefix='temp', name='move_ctrl'): '''Create temporary move control''' ctrl = shapes.makeArrow('{0}_{1}'.format(prefix, name)) ctrl_name = util.nameReformat(ctrl) util.lockCB(ctrl, ['tx', 'tz', 'rx', 'ry', 'rz', 'v']) colourControl(ctrl, 17) return ctrl_name
def tempPlacement(prefix='temp', name='placement_ctrl'): '''Create temporary placement control''' ctrl = shapes.makeCircle('{0}_{1}'.format(prefix, name)) ctrl_name = util.nameReformat(ctrl) util.lockCB(ctrl, ['tx', 'ty', 'tz', 'rx', 'ry', 'rz', 'v']) colourControl(ctrl, 17) return ctrl_name
def toggleReference(ctrl, ref_node): '''Create an attribute to toggle display type''' trName = 'selectable_geo' ctrl_name = util.nameReformat(ctrl) ref_name = util.nameReformat(ref_node) attr_name = '{0}.{1}'.format(ctrl_name, trName) with util.tempSelect(ctrl): cmds.addAttr(ln=trName, at='bool') cmds.setAttr(attr_name) cmds.setAttr(attr_name, channelBox=True) rev_node = reverseNode('{0}_reverse'.format(ctrl_name)) mult_node = multiplyNode('{0}_multi'.format(ctrl_name)) cmds.connectAttr(attr_name, '{0}.inputX'.format(rev_node)) cmds.connectAttr('{0}.outputX'.format(rev_node), '{0}.input1X'.format(mult_node)) cmds.connectAttr('{0}.outputX'.format(mult_node), '{0}.overrideDisplayType'.format(ref_name))
def nullify(ctrl): """Create an empty group to nullify an object's attributes""" ctrl_name = util.nameReformat(ctrl) null_name = '{0}_null'.format(ctrl_name) null_node = null(null_name) util.snap(null_node, ctrl_name) util.parentUnderHierarchy(ctrl_name, null_node) return null_node
def globalScale(ctrl): '''Combine scale attributes into one''' gsName = 'global_scale' ctrl_name = util.nameReformat(ctrl) attr_name = '{0}.{1}'.format(ctrl_name, gsName) with util.tempSelect(ctrl): cmds.addAttr(ln=gsName, at='float') cmds.setAttr(attr_name, 1) cmds.setAttr(attr_name, keyable=True) cmds.connectAttr(attr_name, '{0}.sx'.format(ctrl_name)) cmds.connectAttr(attr_name, '{0}.sy'.format(ctrl_name)) cmds.connectAttr(attr_name, '{0}.sz'.format(ctrl_name)) util.lockCB(ctrl, ['sx', 'sy', 'sz'])
def makeDistance(name='distance', suffixStart='start', suffixEnd='end'): cmds.select(cl=True) dShape = cmds.distanceDimension(sp=(-100, -100, -100), ep=(-100, -99, -100)) dNode_raw = util.nameReformat(cmds.listRelatives(dShape, p=True)) startLoc_raw = util.findFromAttr(dShape, 'startPoint', fromSource=True) endLoc_raw = util.findFromAttr(dShape, 'endPoint', fromSource=True) dNode = cmds.rename(dNode_raw, util.getUniqueName(name)) startLoc = cmds.rename( startLoc_raw, util.getUniqueName('{0}_{1}'.format(name, suffixStart))) endLoc = cmds.rename(endLoc_raw, util.getUniqueName('{0}_{1}'.format(name, suffixEnd))) return dNode, startLoc, endLoc
def colourControl(ctrl, colour=0): '''Colour the control''' ctrl_name = util.nameReformat(ctrl) cmds.setAttr('{0}.overrideEnabled'.format(ctrl_name), 1) cmds.setAttr('{0}.overrideColor'.format(ctrl_name), colour)
def displayReference(ctrl): """Set control's display type to reference""" ctrl_name = util.nameReformat(ctrl) cmds.setAttr('{0}.overrideEnabled'.format(ctrl_name), 1) cmds.setAttr('{0}.overrideDisplayType'.format(ctrl_name), 2)
def reverseNode(name='reverse'): '''Create a reverse node''' node = cmds.shadingNode('reverse', name=name, asUtility=True) node_name = util.nameReformat(node) return node_name