Exemple #1
0
def define(self):
    try:
        _short = self.mNode
        ATTR.set_alias(_short,'sy','blockScale')    
        self.setAttrFlags(attrs=['sx','sz','sz'])
        self.doConnectOut('sy',['sx','sz'])
        ATTR.set_min(_short,'controlOffset',.001)
        
        try:mc.delete(self.getShapes())
        except:pass
    except Exception,err:
        cgmGEN.cgmExceptCB(Exception,err,localDat=vars())    
def SDK_wip(ml = [], matchType = False,
            d_attrs = d_default, skipLever = True, skipFKBase = []):
    _str_func = 'siblingSDK_wip'
    log.info(cgmGEN.logString_start(_str_func))
    
    if not ml:
        ml = cgmMeta.asMeta(sl=1)
    else:
        ml = cgmMeta.asMeta(ml)
    
    #mParent -----------------------------------------------------------------------------
    mParent = ml[0].moduleParent
    mParentSettings = mParent.rigNull.settings
    
    #pprint.pprint([mParent,mParentSettings])
    _settings = mParentSettings.mNode

    #Siblings get ------------------------------------------------------------------------
    #mSiblings = mTarget.atUtils('siblings_get',excludeSelf=False, matchType = matchType)
    mSiblings = ml
    
    md = {}
    d_int = {}
    
    #Need to figure a way to get the order...
    for i,mSib in enumerate(mSiblings):
        log.info(cgmGEN.logString_start(_str_func, mSib.__repr__()))
        
        _d = {}
        
        ml_fk = mSib.atUtils('controls_get','fk')
        if not ml_fk:
            log.warning('missing fk. Skippping...')
            continue
        
        if skipLever or skipFKBase:
            if i in skipFKBase:
                ml_fk = ml_fk[1:]
            elif skipLever and mSib.getMessage('rigBlock') and mSib.rigBlock.getMayaAttr('blockProfile') in ['finger']:
                ml_fk = ml_fk[1:]
            
        #if 'thumb' not in mSib.mNode:
        #    ml_fk = ml_fk[1:]
            
        
        
        _d['fk'] = ml_fk
        ml_sdk = []
        

        
        for ii,mFK in enumerate(ml_fk):
            mSDK = mFK.getMessageAsMeta('sdkGroup')
            if not mSDK:
                mSDK =  mFK.doGroup(True,True,asMeta=True,typeModifier = 'sdk')            
            ml_sdk.append(mSDK)
            
            if not d_int.get(ii):
                d_int[ii] = []
            
            d_int[ii].append(mSDK)
            
        _d['sdk'] = ml_sdk
        
        md[mSib] = _d
        
    #pprint.pprint(md)
    #pprint.pprint(d_int)
    #return
    
    for a,d in d_attrs.iteritems():
        log.info(cgmGEN.logString_sub(_str_func,a))
        for i,mSib in enumerate(mSiblings):
            log.info(cgmGEN.logString_sub(_str_func,mSib))  
            d_sib = copy.deepcopy(d)
            d_idx = d.get(i,{})
            if d_idx:
                _good = True
                for k in ['d','+d','-d','+','-']:
                    if not d_idx.get(k):
                        _good = False
                        break
                if _good:
                    log.info(cgmGEN.logString_msg(_str_func,"Found d_idx on mSib | {0}".format(d_idx))) 
                    d_use = copy.deepcopy(d_idx)
            else:d_use = copy.deepcopy(d_sib)
            
            d2 = md[mSib]
            str_part = mSib.getMayaAttr('cgmName') or mSib.get_partNameBase()
            
            #_aDriver = "{0}_{1}".format(a,i)
            _aDriver = "{0}_{1}".format(a,str_part)
            if not mParentSettings.hasAttr(_aDriver):
                ATTR.add(_settings, _aDriver, attrType='float', keyable = True)            
            
            log.info(cgmGEN.logString_msg(_str_func,"d_sib | {0}".format(d_sib))) 
            for ii,mSDK in enumerate(d2.get('sdk')):
                
                d_cnt = d_idx.get(ii,{}) 
                if d_cnt:
                    log.info(cgmGEN.logString_msg(_str_func,"Found d_cnt on mSib | {0}".format(d_cnt))) 
                    d_use = copy.deepcopy(d_cnt)
                else:d_use = copy.deepcopy(d_sib)
                
                log.info(cgmGEN.logString_msg(_str_func,"{0}| {1} | {2}".format(i,ii,d_use))) 
                
                if d_use.get('skip'):
                    continue                
                
                d_ease = d_use.get('ease',{})
                v_ease = d_ease.get(ii,None)
                
                l_rev = d_sib.get('reverse',[])
                
                if  issubclass( type(d_use['d']), dict):
                    d_do = d_use.get('d')
                else:
                    d_do = {d_use['d'] : d_use}
                    
                    
                for k,d3 in d_do.iteritems():
                    
                    if d3.get('skip'):
                        continue

                    mc.setDrivenKeyframe("{0}.{1}".format(mSDK.mNode, k),
                                         currentDriver = "{0}.{1}".format(_settings, _aDriver),
                                         itt='linear',ott='linear',                                         
                                         driverValue = 0, value = 0)
                    
                    #+ ------------------------------------------------------------------
                    pos_v = d3.get('+')
                    pos_d = d_use.get('+d', 1.0)
                    if v_ease is not None:
                        pos_v = pos_v * v_ease
                    
                    if i in l_rev:
                        print("...rev pos")
                        pos_v*=-1
                    
                    ATTR.set_max("{0}.{1}".format(_settings, _aDriver),pos_d)
                    
                    if pos_v:
                        mc.setDrivenKeyframe("{0}.{1}".format(mSDK.mNode, k),
                                         currentDriver = "{0}.{1}".format(_settings, _aDriver),
                                         itt='linear',ott='linear',                                         
                                         driverValue = pos_d, value = pos_v)
                    
                    
                    #- ----------------------------------------------------------
                    neg_v = d3.get('-')
                    neg_d = d_use.get('-d', -1.0)
                    if v_ease is not None:
                        neg_v = neg_v * v_ease                
                    
                    if i in l_rev:
                        print("...rev neg")                        
                        neg_v*=-1
                            
                    ATTR.set_min("{0}.{1}".format(_settings, _aDriver),neg_d)
                        
                    if neg_v:
                        mc.setDrivenKeyframe("{0}.{1}".format(mSDK.mNode, k),
                                         currentDriver = "{0}.{1}".format(_settings, _aDriver),
                                         itt='linear',ott='linear',                                         
                                         driverValue = neg_d, value = neg_v)