def patch_spaceswitch_dpspine_objects():
    """
    This function is not clean, but it can be used to generate spaceswitch object for certain module and after look at
    all space switch target information to replace to space switch object target that could used a ctrl to the new space
    switch object that will not be removed after an unbuild
    """

    # Get the rig instance in the scene (Now support only the first one found
    rig_net = libSerialization.get_networks_from_class('Rig')[0]
    rig_instance = libSerialization.import_network(rig_net)

    # Get all the module that we could need to patch
    to_patch = [module for module in rig_instance.modules if isinstance(module, rigDpSpine.DpSpine)]

    for module in to_patch:
        module_to_patch = module
        if isinstance(module_to_patch, rigDpSpine.DpSpine):
            # Find all connection that have from the ctrl ik down (COG) and replace it
            connected_to_fk_dwn = module_to_patch.ctrl_fk_dwn._network.message.outputs(s=False, d=True, p=True)

            for connection in connected_to_fk_dwn:
                attr_name = connection.shortName()
                if attr_name.find('targets') >= 0:
                    log.info('Reconnecting {0} from {1} to space switch node {2}'
                             .format(connection, module_to_patch.ctrl_ik_dwn, module_to_patch.ctrl_ik_dwn._network))
                    connection.disconnect()
                    pymel.connectAttr(module_to_patch.ctrl_ik_dwn._network.message, connection, force=True)
Example #2
0
def find():
    """
    :return: All the rigs embedded in the current maya scene.
    """
    # TODO: Find why when a scene is open for a long time, this function is slower
    networks = libSerialization.get_networks_from_class('Rig')
    results = [libSerialization.import_network(network, module='omtk') for network in networks]
    results = filter(None, results)  # Prevent un-serializable networks from passing through.
    return results
Example #3
0
def _get_holded_shapes():
    """
    :return: The numbers of shapes connected to anm ctrls in the whole scene.
    """
    shapes = []
    for net in libSerialization.get_networks_from_class('BaseCtrl'):
        if net.hasAttr('shapes'):
            shapes.extend(net.shapes.inputs())
    return shapes
Example #4
0
def unbuild_all(strict=False):
    networks = libSerialization.get_networks_from_class('Rig')
    for network in networks:
        rigroot = libSerialization.import_network(network)
        if not rigroot:
            log.warning("Error importing rig network {0}".format(network))
            continue
        rigroot.unbuild(strict=strict)
        pymel.delete(network)
        # Write changes to scene
        network = libSerialization.export_network(rigroot)
        pymel.select(network)
Example #5
0
def unbuild_all(strict=False):
    networks = libSerialization.get_networks_from_class('Rig')
    for network in networks:
        rigroot = libSerialization.import_network(network)
        if not rigroot:
            log.warning("Error importing rig network {0}".format(network))
            continue
        rigroot.unbuild(strict=strict)
        pymel.delete(network)
        # Write changes to scene
        network = libSerialization.export_network(rigroot)
        pymel.select(network)
Example #6
0
def build_all(strict=False):
    """
    Build all the rigs embedded in the current maya scene.
    """
    networks = libSerialization.get_networks_from_class('Rig')
    for network in networks:
        rigroot = libSerialization.import_network(network)
        if not rigroot:
            log.warning("Error importing rig network {0}".format(network))
            continue
        if rigroot.build(strict=strict):
            pymel.delete(network)
            libSerialization.export_network(rigroot)
Example #7
0
def build_all(strict=False):
    """
    Build all the rigs embedded in the current maya scene.
    """
    networks = libSerialization.get_networks_from_class('Rig')
    for network in networks:
        rigroot = libSerialization.import_network(network)
        if not rigroot:
            log.warning("Error importing rig network {0}".format(network))
            continue
        if rigroot.build(strict=strict):
            pymel.delete(network)
            libSerialization.export_network(rigroot)
Example #8
0
def find():
    """
    :return: All the rigs embedded in the current maya scene.
    """
    # TODO: Find why when a scene is open for a long time, this function is slower
    networks = libSerialization.get_networks_from_class('Rig')
    results = [
        libSerialization.import_network(network, module='omtk')
        for network in networks
    ]
    results = filter(
        None,
        results)  # Prevent un-serializable networks from passing through.
    return results
Example #9
0
def patch_spaceswitch_dpspine_objects():
    """
    This function is not clean, but it can be used to generate spaceswitch object for certain module and after look at
    all space switch target information to replace to space switch object target that could used a ctrl to the new space
    switch object that will not be removed after an unbuild
    """

    # Get the rig instance in the scene (Now support only the first one found
    rig_net = libSerialization.get_networks_from_class('Rig')[0]
    rig_instance = libSerialization.import_network(rig_net)

    # Get all the module that we could need to patch
    to_patch = [
        module for module in rig_instance.modules
        if isinstance(module, rigDpSpine.DpSpine)
    ]

    for module in to_patch:
        module_to_patch = module
        if isinstance(module_to_patch, rigDpSpine.DpSpine):
            # Find all connection that have from the ctrl ik down (COG) and replace it
            connected_to_fk_dwn = module_to_patch.ctrl_fk_dwn._network.message.outputs(
                s=False, d=True, p=True)

            for connection in connected_to_fk_dwn:
                attr_name = connection.shortName()
                if attr_name.find('targets') >= 0:
                    log.info(
                        'Reconnecting {0} from {1} to space switch node {2}'.
                        format(connection, module_to_patch.ctrl_ik_dwn,
                               module_to_patch.ctrl_ik_dwn._network))
                    connection.disconnect()
                    pymel.connectAttr(
                        module_to_patch.ctrl_ik_dwn._network.message,
                        connection,
                        force=True)
Example #10
0
 def _get_holded_shapes(self):
     shapes = []
     for net in libSerialization.get_networks_from_class('BaseCtrl'):
         if net.hasAttr('shapes'):
             shapes.extend(net.shapes.inputs())
     return shapes
Example #11
0
 def _get_holded_shapes(self):
     shapes = []
     for net in libSerialization.get_networks_from_class('BaseCtrl'):
         if net.hasAttr('shapes'):
             shapes.extend(net.shapes.inputs())
     return shapes