Beispiel #1
0
def CallFnOnNetworkByClass(_sFn, _sCls):
    fnFilter = lambda x: libSerialization.isNetworkInstanceOfClass(x, _sCls)
    networks = libSerialization.getConnectedNetworks(pymel.selected(), key=fnFilter)
    for network in networks:
        rigPart = libSerialization.import_network(network)

        if not hasattr(rigPart, _sFn):
            logging.warning("Can't find attribute {0} in {1}".format(_sFn, network)); continue

        try:
            getattr(rigPart, _sFn)()
        except Exception, e:
            print str(e)
Beispiel #2
0
def is_network_pinnable(network):
    from omtk.libs import libSerialization
    from omtk.rigging.autorig.classRigPart import RigPart
    if not isinstance(network, pymel.nodetypes.Network):
        raise IOError("Expected pymel.nodetypes.Network, got {0} ({1})".format(network, type(network)))

    # We only listen to network that inherit from RigPart
    if not libSerialization.isNetworkInstanceOfClass(network, RigPart.__name__):
        return False

    # If the network have an 'canPinTo' attribute
    # todo: Don't hardcode attribute name...
    if network.hasAttr('canPinTo'):
        val = network.attr('canPinTo').get()
        if not isinstance(val, bool):
            raise IOError("Expected 'canPinTo' attribute type to be boolean, got {0} ({1})".format(val, type(val)))
    else:
        log.warning("Can't find attribute 'canPinTo' in {0}, maybe the network is old and need to be re-generated?".format(network))

    # If there's no 'canPinTo' attribute we assume that the network is not pinnable.
    return False