Пример #1
0
 def _targetMatch(self, *args):
     args=pm.ls(sl=True)
     for arg in args:
         if pm.objExists(arg+'.target'):
             tgt= pm.PyNode(arg.target.get())
         elif pm.objExists(nami.replaceSuffix(arg+'GEO')): tgt = pm.PyNode(arg.target.get())
         else:
             print 'Couldn\'t find target for object: %s ...skipping' % arg
             break
         posi.matchPos(arg, [tgt], 1)
Пример #2
0
def xpop(args=[], type='LOC', space=1, addSuffix='', parent=''):
    '''
    Function: takes args and matchesPos + duplicates specified type onto each arg
    Args = type=str, space=int, addSuffix=str, parent=str
    State: type=one of ['LOC','PLANE','CUBE','JNT','GRP','CAM','SLGT','DLGT','PLGT','ALGT']
                if in list of prespecified objects, will populate across. Explained:
                locator, plane, cube, joint, group, camera,
                spotlight, directional light, point light, area light
           
                space=1-4: check help for _SCRIPTS._LAYOUT.lib_position.matchPos for instruction on this
                           otherwise leave default
    Returns: list of PyNode(type)
    Example Usage: xpop(type='JNT', addSuffix='TEMP')
    '''
    print 'Populating type: %s' % type
    suffixes=['LOC','PLANE','CUBE','JNT','GRP','CAM','SLGT','DLGT','PLGT','ALGT']
    if type.upper() in suffixes or pm.objExists(type):
        if args==[]: args = pm.ls(sl=True)
        #Create or store group
        if parent=='': grp = 'populate_'+type+'_GRP'
        else: grp = parent
        
        if not pm.objExists(grp):
            grp = pm.group(em=True, n=grp)
        else: grp = pm.PyNode(grp)
        result=[]
        print type
        for arg in args:
            if addSuffix=='':
                pop = nami.replaceSuffix(type,args=arg.name(),validSuffix=True)
            else: pop = arg.name()+addSuffix
            
            if not pm.objExists(pop):
                if type=='LOC':
                    pop = pm.spaceLocator(n=pop)
                elif type=='PLANE':
                    pop = pm.polyPlane(n=pop,sx=1, sy=1)[0]
                elif type=='CUBE':
                    pop = pm.polyCube(n=pop)[0]
                elif type=='JNT':
                    pop = pm.joint( n=pop )
                    pop.radius.set(10)
                elif type=='GRP':
                    pop = pm.group(em=True,n=pop)
                elif type=='CAM':
                    pop = pm.camera(n=pop)[0]
                elif type=='SLGT':
                    pop = pm.spotLight().listRelatives(p=True)[0].rename(pop)
                elif type=='DLGT':
                    pop = pm.directionalLight().listRelatives(p=True)[0].rename(pop)
                elif type=='PLGT':
                    pop = pm.pointLight().listRelatives(p=True)[0].rename(pop)
                elif type=='ALGT':
                    pop = pm.createNode('areaLight').listRelatives(p=True)[0].rename(pop)
                else:
                    pop = pm.duplicate(type)[0]
            posi.matchPos(src=arg, args=[pop], type=1)
            pop.addAttr('target',dt='string')
            pop.target.set( arg )
            pop.setParent( grp )
            result.append(pop)
    else: pm.error('Unsupported object type, check the help() for supported types')
    return result