Example #1
0
def loadCustomMirrorSettings(node):
    """Get custom mirror data from a node.

    Args:
        node (pm.PyNode): Node to find mirror options on.

    Returns:
        dict
    """
    result = {}
    if not isCustomMirrorNode(node):
        return result

    data = mirrorData.getMirrorData(node)

    if 'customMirror' not in data or 'settings' not in data['customMirror']:
        raise KeyError("Custom Mirror node missing settings")

    settingsStr = data['customMirror']['settings']
    result = ast.literal_eval(settingsStr)

    # Put in a translation layer to allow more flexibility in butterfly rigs between versions
    mirrorMode = result.get('mirrorMode', None)

    # backwards compatibility
    if mirrorMode is None:
        mirrorMode = 'simple' if result.get('axesMirrored', True) else 'inverse'

    settings = {
        'mirrorMode': mirrorMode,
        'customMirrorAttrExps': dict([(attr, data['exp']) for attr, data in result.get('customMirrorAttrs', {}).items()]),
    }

    return settings
Example #2
0
def isCustomMirrorNode(node):
    """Check if input node has custom mirror data.

    Args:
        node (pm.PyNode): Node to check.

    Returns:
        bool
    """
    return mirrorData.hasMirrorData(node) and 'customMirror' in mirrorData.getMirrorData(node)
Example #3
0
def getMirrorMode(node):
    """Get the mirror mode of the given node.

    Args:
        node (pm.PyNode): Node to check.

    Returns:
        str
    """
    return mirrorData.getMirrorData(node, 'mirrorMode')
Example #4
0
def getMirrorNode(node, warn=False):
    """Given a mirror node, find the counter part.

    Args:
        node (pm.PyNode): Source node name to get mirror node.
        warn (bool): Warn user if the source has no mirror.

    Returns:
        str: Name of the source node's mirror node.
    """
    if not isMirrorNode(node):
        if warn:
            LOG.warning('{0} is not a mirror node'.format(node))
        return

    return mirrorData.getMirrorData(node, 'mirrorNode')
Example #5
0
def validateMirrorNode(node):
    """Check if the given mirror node still has a mirror object.
    Otherwise remove the mirror meta data from the node.

    Args:
        node (pm.PyNode): Name of a node.

    Returns:
        bool: True if the node is a valid mirror node.
    """
    if not mirrorData.hasMirrorData(node):
        return False

    mirrorNode = mirrorData.getMirrorData(node, 'mirrorNode')
    if mirrorNode is None:
        LOG.debug('{0} mirror node was None, clearing mirror node'.format(node))
        clearMirrorNode(node)
        return False

    return True
Example #6
0
def setMirrorNode(node, mirrorNode, force=False):
    """Set a given node's mirror node.

    Args:
        node (pm.PyNode): Name of the source node.
        mirrorNode (pm.PyNode): Name of the destination node.
        force (bool): Override any mirroring that exists.

    Returns:
        None
    """
    data = mirrorData.getMirrorData(node, 'mirrorNode')

    if mirrorData.hasMirrorData(node):
        if not force and data != mirrorNode and data is not None:
            LOG.warning('{0} is already associated with another node {1}, use force=True to replace with {2}'.format(node, data, mirrorNode))
            return

    mirrorData.setMirrorData(node, key='mirrorNode', value=mirrorNode)
    mirrorData.setMirrorData(node, key='mirrorMode', value='Auto')