-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathmappingUtils.py
42 lines (28 loc) · 921 Bytes
/
mappingUtils.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
from names import *
from apiExtensions import *
def findItem( itemName ):
itemName = str( itemName )
if cmd.objExists( itemName ):
return itemName
match = matchNames( itemName, cmd.ls( type='transform' ) )[ 0 ]
if match:
return match
return None
def resolveMappingToScene( mapping, threshold=1.0 ):
'''
takes a mapping and returns a mapping with actual scene objects
'''
assert isinstance( mapping, Mapping )
toSearch = cmd.ls( typ='transform' )
existingSrcs = []
existingTgts = []
for src, tgt in mapping.iteritems():
if not cmd.objExists( src ):
src = matchNames( [ src ], toSearch, **kw )[ 0 ]
if not cmd.objExists( tgt ):
tgt = matchNames( [ tgt ], toSearch, **kw )[ 0 ]
if cmd.objExists( src ) and cmd.objExists( tgt ):
existingSrcs.append( src )
existingTgts.append( tgt )
return Mapping( existingSrcs, existingTgts )
#end