Beispiel #1
0
def customAttrsSampling(attrData, interval=1):
    """
    Args:
      attrData (dict): {node1: [[attr1, min, max], [attr2, min, max], ...],
                        node2: [[attr1, min, max], [attr2, min, max], ...],
                        ...}
      interval (int)
    
    Returns:
      int
    """
    start = cmds.currentTime(q=1)
    currTime = attrsSampling(attrData, interval)
    end = currTime-1
    utils.trimTimeRange(start, end)
    cmds.currentTime(start) 
Beispiel #2
0
def transformSampling(translateMin, translateMax,
                      rotateMin, rotateMax,
                      scaleMin, scaleMax,
                      isTranslate, isRotate, isScale,
                      translateAttrs = ('tx', 'ty', 'tz'),
                      rotateAttrs = ('rx', 'ry', 'rz'),
                      scaleAttrs = ('sx', 'sy', 'sz'),
                      interval=1):
    """
    Args:
      translateMin (float)
      translateMax (float)
      rotateMin (float)
      rotateMax (float)
      scaleMin (float)
      scaleMax (float)
      isTranslate (bool)
      isRotate (bool)
      isScale (bool)
      interval (int)
    """
    start = cmds.currentTime(q=1)
    sel = cmds.ls(sl=1, ap=1)
    if not sel:
        om.MGlobal.displayError("Please select some tranform nodes.")
        return
    
    attrData = {}    
    for node in sel:
        if not attrData.has_key(node):
            attrData[node] = []
            
        if isRotate:
            [attrData[node].append([attr, rotateMin, rotateMax]) for attr in rotateAttrs]
            
        if isTranslate:
            [attrData[node].append([attr, translateMin, translateMax]) for attr in translateAttrs]
        
        if isScale:
            [attrData[node].append([attr, scaleMin, scaleMax]) for attr in scaleAttrs]
    
    currTime = attrsSampling(attrData, interval)
            
    end = currTime-1
    utils.trimTimeRange(start, end)
    cmds.currentTime(start)    
Beispiel #3
0
def blendShapeSampling(node, interval=1):
    """
    Args:
      node (str)
      interval (int)
    
    Returns:
      int
    """
    assert cmds.nodeType(node) == 'blendShape', \
        "node must be a blendShape type"
    start = cmds.currentTime(q=1)
    
    attrs = cmds.listAttr('%s.weight' % node, m=1)
    attrData = {node: [[attr, 0.0, 1.0] for attr in attrs]}
    
    currTime = attrsSampling(attrData, interval)

    end = currTime-1
    utils.trimTimeRange(start, end)
    cmds.currentTime(start)