Ejemplo n.º 1
0
def get_driver(driven=None, getPlug=True, select=True):
    """
    Get the driver objects or plugs by following the anim curve out of our intial driven
    
    :parameters:
        driven(str): Attribute to map. If none provided, checks selection
        getPlug(bool): Whether to get plug or node
        select(bool): Select the result

    :returns
        driven
    """
    _str_func = 'get_driver'

    driven = VALID.listArg(driven)
    if not driven:
        driven = SEARCH.get_selectedFromChannelBox(False) or []

    log.debug("|{0}| >> Driven: {1}".format(_str_func, driven))
    if not driven:
        log.error(
            "|{0}| >> No driven found or offered. Try selecting an attribute that is an sdk driven"
            .format(_str_func))
        return False
    l_driver = []
    for d in driven:
        _buffer = mc.listConnections(d, scn=True, s=True, d=False) or []
        if not _buffer:
            log.error("|{0}| >> Driven: {1} | No data found".format(
                _str_func, d))
        for c in _buffer:
            log.debug("|{0}| >> Checking: {1}".format(_str_func, c))
            #b_transform = VALID.is_transform(c)
            #if not b_transform:
            l_driver.append(
                SEARCH.seek_upStream(c, mode='isTransform', getPlug=getPlug))

    l_driver = LISTS.get_noDuplicates(l_driver)
    if not l_driver:
        log.error("|{0}| >> No driver found".format(_str_func))
        return False
    if select:
        mc.select(l_driver)
        pprint.pprint(l_driver)
    return l_driver
Ejemplo n.º 2
0
def setKey(keyModeOverride = None):
    _str_func = "setKey"        
    KeyTypeOptionVar = cgmMeta.cgmOptionVar('cgmVar_KeyType', defaultValue = 0)
    KeyModeOptionVar = cgmMeta.cgmOptionVar('cgmVar_KeyMode', defaultValue = 0)	
    selection = False
    
    log.debug("|{0}| >> keyType: {1} | keyMode: {2} |  keyModeOverride: {3}".format(_str_func,KeyTypeOptionVar.value,KeyModeOptionVar.value,keyModeOverride))  
    
    if not KeyModeOptionVar.value:#This is default maya keying mode
        selection = mc.ls(sl=True) or []
        if not selection:
            return log.warning('cgmPuppetKey.setKey>>> Nothing l_selected!')
           
            
        """if not KeyTypeOptionVar.value:
            mc.setKeyframe(selection)
        else:
            mc.setKeyframe(breakdown = True)"""
    else:#Let's check the channel box for objects
        selection = SEARCH.get_selectedFromChannelBox(False) or []
        if not selection:
            log.debug("|{0}| >> No channel box selection. ".format(_str_func))
            selection = mc.ls(sl=True) or []
            
            
    if not selection:
        return log.warning('cgmPuppetKey.setKey>>> Nothing selected!')
    
            
    if keyModeOverride:
        log.debug("|{0}| >> Key override mode. ".format(_str_func))
        if keyModeOverride== 'breakdown':
            mc.setKeyframe(selection,breakdown = True)     
        else:
            mc.setKeyframe(selection)
            
    else:
        if not KeyTypeOptionVar.value:
            mc.setKeyframe(selection)
        else:
            mc.setKeyframe(selection,breakdown = True)