Ejemplo n.º 1
0
def lsNodes(*args, **kwargs):

    bAsNodeName = kwargs.pop('nodeNames', False)

    bPrune = False
    pruneKwargs = {}
    for k in kwargs.keys():

        if k.startswith("not_"):
            v = kwargs.pop(k)
            pruneKwargs[k.split("not_", 1)[1]] = v

            if (not bPrune) and v:
                bPrune = True

    _lsCmd = pm.ls
    if (bPrune or bAsNodeName):
        _lsCmd = mc.ls
        args = tuple(pynodeToStr(arg) for arg in args)

    nodeList = listForNone(_lsCmd(*args, **kwargs))
    if not nodeList:
        return nodeList

    if bPrune:
        nodeList = pruneNodeList(nodeList, **pruneKwargs)
        if not bAsNodeName:
            return list(pm.PyNode(n) for n in nodeList)

    return nodeList
Ejemplo n.º 2
0
def lsNodes(*args, **kwargs):

    bAsNodeName = kwargs.pop('nodeNames', False)

    bPrune = False
    pruneKwargs = {}
    for k in kwargs.keys():

        if k.startswith("not_"):
            v = kwargs.pop(k)
            pruneKwargs[k.split("not_", 1)[1]] = v

            if (not bPrune) and v:
                bPrune = True

    _lsCmd = pm.ls
    if (bPrune or bAsNodeName):
        _lsCmd = mc.ls
        args = tuple(pynodeToStr(arg) for arg in args)

    nodeList = listForNone(_lsCmd(*args, **kwargs))
    if not nodeList:
        return nodeList

    if bPrune:
        nodeList = pruneNodeList(nodeList, **pruneKwargs)
        if not bAsNodeName:
            return list(pm.PyNode(n) for n in nodeList)

    return nodeList
Ejemplo n.º 3
0
def iterAttrsUsedAsFilename(*args, **kwargs):

    kwargs.update(nodeNames=True, ni=True,
                  not_defaultNodes=True,
                  not_references=True,)

    sNodeList = lsNodes(*args, **kwargs)

    for sNode in sNodeList:
        for sAttr in listForNone(mc.listAttr(sNode, usedAsFilename=True)):
            sAttr = sAttr.split(".", 1)[0]
            sNodeAttr = sNode + "." + sAttr
            sType = mc.getAttr(sNodeAttr, type=True)
            if sType == "string":
                yield sNodeAttr
Ejemplo n.º 4
0
def iterAttrsUsedAsFilename(*args, **kwargs):

    kwargs.update(nodeNames=True, ni=True,
                  not_defaultNodes=True,
                  not_references=True,)

    sNodeList = lsNodes(*args, **kwargs)

    for sNode in sNodeList:
        for sAttr in listForNone(mc.listAttr(sNode, usedAsFilename=True)):
            sAttr = sAttr.split(".", 1)[0]
            sNodeAttr = sNode + "." + sAttr
            sType = mc.getAttr(sNodeAttr, type=True)
            if sType == "string":
                yield sNodeAttr
Ejemplo n.º 5
0
def iterRenderLayerOverrides(sLayerName):

    for idx in listForNone(mc.getAttr(sLayerName + ".adjustments", multiIndices=True)):

        sLyrAttr = sLayerName + ".adjustments[{}]".format(idx)
        sInAttrList = mc.listConnections(sLyrAttr + ".plug", s=True, d=False, plugs=True)
        if not sInAttrList:
            continue

        sInPlugAttr = sInAttrList[0]

        sInAttrList = mc.listConnections(sLyrAttr + ".value", s=True, d=False, plugs=True)
        if sInAttrList:
            value = sInAttrList[0]
        else:
            value = mc.getAttr(sLyrAttr + ".value")

        yield (sInPlugAttr, value)