Exemplo n.º 1
0
def getVisGroup(obj):
    '''
    Returns ('name', int:level) if it's in a group, otherwise an empty tuple.
    '''
    
    zero = core.dagObj.zero(obj, apply=False, make=False)
    if zero:
        obj = zero
        
    visCon = cmds.listConnections(obj.visibility.name(), p=True, s=True, d=False)
    if visCon:
        node, attr = visCon[0].rsplit('|')[-1].split('.')
        shape = get(create=False)
        
        level = 1
        
        if nodeType(node) == 'condition' and attr == 'outColorR':
            con = listConnections(node + '.firstTerm', p=True, s=True, d=False)
            if con:
                level = int(getAttr(node + '.secondTerm'))
                node = shortName(con[0].node())
                attr = con[0].attrName()
                print(node, 'NODE')
        
        if shape and shape.endswith('|' + node):
            return attr, level
        
    return ()
Exemplo n.º 2
0
def _processAttr(plug, dups, forceKeys, staticValues, start, end):
    '''
    Used by `save`
    '''

    crvs = cmds.listConnections(plug, type='animCurve')

    if not crvs:
        if forceKeys:
            setKeyframe(plug, t=start)
            setKeyframe(plug, t=end)
            crvs = cmds.listConnections(plug, type='animCurve')
        else:
            if not cmds.getAttr(plug, lock=True) and not cmds.listConnections(
                    plug, s=True, d=False):
                staticValues[plug] = cmds.getAttr(plug)

    if crvs:
        dup = cmds.duplicate(crvs)[0]
        if not objExists(dup + '.' + TAGGING_ATTR):
            cmds.addAttr(dup, ln=TAGGING_ATTR, dt='string')
        cmds.setAttr(dup + '.' + TAGGING_ATTR, plug, type='string')
        dups.append(dup)
Exemplo n.º 3
0
def getVisGroup(obj):
    zero = core.dagObj.zero(obj, apply=False, make=False)
    if zero:
        obj = zero

    visCon = cmds.listConnections(obj.visibility.name(),
                                  p=True,
                                  s=True,
                                  d=False)
    if visCon:
        node, attr = visCon[0].rsplit('|')[-1].split('.')
        shape = get(create=False)
        if shape and shape.endswith('|' + node):
            return attr

    return ''
Exemplo n.º 4
0
def updateVisGroupConnections():
    '''
    Any controller who's vis is connected directly to the lib.sharedShape gets it
    moved to the zeroGroup.
    
    Skips over things hooked up to switch attrs.
    '''

    for ctrl in core.findNode.controllers():
        visCon = cmds.listConnections(ctrl.visibility.name(),
                                      p=True,
                                      s=True,
                                      d=False)
        if visCon:
            node, attr = visCon[0].rsplit('|')[-1].split('.')
            shape = lib.sharedShape.get(create=False)
            if shape and shape.endswith('|' +
                                        node) and not attr.endswith('_Switch'):

                zero = core.dagObj.zero(ctrl, apply=False, make=False)
                if zero:

                    if ctrl.visibility.isLocked():
                        ctrl.visibility.unlock()
                        relock = True
                    else:
                        relock = False

                    disconnectAttr(visCon[0], ctrl.visibility)

                    cmds.connectAttr(visCon[0], zero.visibility.name(), f=True)

                    ctrl.visibility.set(1)

                    if relock:
                        ctrl.visibility.lock()

                    print('fixed', ctrl)
                else:
                    print('FAIL', ctrl)