def getPoseInterp(node): node = common.getFirstIndex(node) if mc.nodeType(node) == 'transform': shape = common.getFirstIndex(mc.listRelatives(node, s=1, ni=1)) if shape: node = shape if mc.nodeType(node) == 'poseInterpolator': return (node)
def removePoseControl(interp, controlAttr): controlAttr = common.getFirstIndex(controlAttr) interp = getInterp(interp) poseInterpAttrs = mc.ls(interp + '.driver[0].driverController[*]') control = controlAttr.split('.')[0] for attr in poseInterpAttrs: conControl = common.getFirstIndex(mc.listConnections(attr)) if control == conControl: logger.info('disconnecting: %s %s ', controlAttr, attr) mc.disconnectAttr(controlAttr, attr)
def removePoseControl(poseInterp, controlAttr): controlAttr = common.getFirstIndex(controlAttr) poseInterp = getPoseInterp(poseInterp) poseInterpAttrs = mc.ls(poseInterp + '.driver[0].driverController[*]') control = controlAttr.split('.')[0] for attr in poseInterpAttrs: conControl = common.getFirstIndex(mc.listConnections(attr)) conControlAttr = common.getFirstIndex(mc.listConnections(attr, p=1)) if control == conControl: print('disconnecting', controlAttr, attr) mc.disconnectAttr(controlAttr, attr)
def getInterp(node): ''' Used to convert a dag node to the interpolator node. If a transform is passed a interpoloator shape is returned. If the node is a shape and an interpolator, it is just passed through. :param node: Any dag node. :return: interpoloator node related to the passed node ''' node = common.getFirstIndex(node) if mc.nodeType(node) == 'transform': shape = common.getFirstIndex(mc.listRelatives(node, s=1, ni=1)) if shape: node = shape if mc.nodeType(node) == 'poseInterpolator': return(node)
def getGroup(poseInterp): poseInterp = getPoseInterp(poseInterp) if not poseInterp: return con = mc.listConnections(poseInterp + '.midLayerParent', p=1) con = common.getFirstIndex(con) index = int(con.split('[')[1].replace(']', '')) groups = mc.ls(manager + '.poseInterpolatorDirectory[*]') for group in groups: name = mc.getAttr(group + '.directoryName') childIndices = mc.getAttr(group + '.childIndices') if index in childIndices: return (name)
def getGroupChildren(group): groupAttrs = mc.ls(manager + '.poseInterpolatorDirectory[*]') for groupAttr in groupAttrs: name = mc.getAttr(groupAttr + '.directoryName') if name != group: continue childAttrs = mc.getAttr(groupAttr + '.childIndices') children = list() for childAttr in childAttrs: child = mc.listConnections( manager + '.poseInterpolatorParent[{}]'.format(childAttr)) child = common.getFirstIndex(child) child = getPoseInterp(child) if child: children.append(child) return (children)
def getGroupChildren(group): # Directories are any pose interpoloator group groupAttrs = mc.ls(manager + '.poseInterpolatorDirectory[*]') for groupAttr in groupAttrs: name = mc.getAttr(groupAttr + '.directoryName') if name != group: continue childAttrs = mc.getAttr(groupAttr + '.childIndices') if not childAttrs: return [] children = list() for childAttr in childAttrs: childAttr = int(childAttr) # The child index is -2 if there are no children # or if the only child is a group, guessing... if childAttr == -2: continue child = mc.listConnections(manager+'.poseInterpolatorParent[{}]'.format(childAttr)) child = common.getFirstIndex(child) child = getInterp(child) if child: children.append(child) return(children)