コード例 #1
0
ファイル: cbox_dock.py プロジェクト: bballout/MayaTools
 def set_attr_key(self, action='key'):
     """Set/delete/mute/unmute keys.
        Actions: 'key', 'delete', 'mute', 'unmute'"""
     attrs = self.get_selected_attrs(mains=True,
                                     shapes=True,
                                     history=True,
                                     outputs=True,
                                     flatten=True,
                                     error=False)
     if not attrs:
         attrs = self.get_default_attrs(flatten=True)
     for a in attrs:
         if action == 'key':
             try:
                 cmds.setKeyframe(a)
             except RuntimeError as e:
                 cmds.warning('%s' % e)
         elif action == 'delete':
             try:
                 cmds.cutKey(a, cl=True)
             except RuntimeError as e:
                 cmds.warning('%s' % e)
         elif action == 'mute':
             try:
                 cmds.mute(a)
             except RuntimeError as e:
                 cmds.warning('%s' % e)
         elif action == 'unmute':
             try:
                 cmds.mute(a, disable=True, force=True)
             except RuntimeError as e:
                 cmds.warning('%s' % e)
     return
コード例 #2
0
def unmute_and_show_node(node):
    """ Un-mutes the visibility attribute on the given node and show it

    Args:
        node (str): node to unmute and show
    """

    # we query connections and hide from the mute node
    if cmds.listConnections("{}.visibility".format(node)):
        cmds.mute("{}.visibility".format(node), disable=True, force=True)

    # we simply hide
    else:
        cmds.setAttr("{}.visibility".format(node), 1)
コード例 #3
0
def set_deformer_on(deformer):
    """ Set envelope attribute to **1** on the given deformer

    :param deformer: deformer node
    :type deformer: str
    """

    # sets attribute to zero
    try:
        cmds.setAttr("{}.envelope".format(deformer), 1)

    # if connections are found on the attribute then mute node is removed
    except RuntimeError:
        cmds.mute("{}.envelope".format(deformer), disable=True, force=True)
コード例 #4
0
def attribute_mute(attr_mute):
    """Mute animated attributes

    Arguments:
        attr_mute (list): A list of attribute names

    """
    original = [(attr, cmds.mute(attr, query=True)) for attr in attr_mute]
    try:
        for attr in attr_mute:
            cmds.mute(attr)
        yield

    finally:
        for attr, mutted in original:
            if not mutted:
                cmds.mute(attr, disable=True)
コード例 #5
0
def set_deformer_off(deformer):
    """ Set envelope attribute to **0** on the given deformer

    :param deformer: deformer node
    :type deformer: str
    """

    # sets attribute to zero
    try:
        cmds.setAttr("{}.envelope".format(deformer), 0)

    # if connections are found on the attribute then mute node is used
    except RuntimeError:
        mute_node = cmds.mute("{}.envelope".format(deformer), force=True)[0]
        cmds.setAttr("{}.hold".format(mute_node), 0)
コード例 #6
0
def mute_and_hide_node(node):
    """ Mutes the visibility attribute on the given node and hides it

    Args:
        node (str): node to mute and hide
    """

    # we query connections and hide from the mute node
    if cmds.listConnections("{}.visibility".format(node)):
        _mute = cmds.mute("{}.visibility".format(node))
        # we deferre hiding with the mute node due to Maya bullshit
        cmds.evalDeferred("cmds.setAttr('{}.hold', False)".format(_mute[0]))

    # we simply hide
    else:
        cmds.setAttr("{}.visibility".format(node), False)
コード例 #7
0
ファイル: animation.py プロジェクト: zewt/pymel
def mute(*args, **kwargs):
    res = cmds.mute(*args, **kwargs)
    if not kwargs.get('query', kwargs.get('q', False)):
        res = _factories.maybeConvert(res, _general.PyNode)
    return res
コード例 #8
0
def muteWorld(world):
    cmds.currentTime(1)
    cmds.mute(str(world) + '.translateZ')
    cmds.mute(str(world) + '.translateX')
    cmds.mute(str(world) + '.translateY')
    cmds.mute(str(world) + '.rotateZ')
    cmds.mute(str(world) + '.rotateX')
    cmds.mute(str(world) + '.rotateY')