-
Notifications
You must be signed in to change notification settings - Fork 62
/
select_object_set.py
56 lines (41 loc) · 1.69 KB
/
select_object_set.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import publish.lib
import publish.config
import publish.plugin
import maya.cmds as cmds
@publish.lib.log
class SelectObjectSet(publish.plugin.Selector):
"""Select instances of node-type 'transform'
Opens up the doors for instances containing nodes of any type,
but lacks the ability to be nested with DAG nodes.
E.g. -> /root/MyCharacter.publishable/an_object_set
"""
hosts = ['maya']
version = (0, 1, 0)
def process(self, context):
for objset in cmds.ls("*." + publish.config.identifier,
objectsOnly=True,
type='objectSet'):
instance = publish.domain.Instance(name=objset)
self.log.info("Adding instance: {0}".format(objset))
for node in cmds.sets(objset, query=True):
if cmds.nodeType(node) == 'transform':
descendents = cmds.listRelatives(node,
allDescendents=True)
for descendent in descendents:
instance.add(descendent)
else:
instance.add(node)
attrs = cmds.listAttr(objset, userDefined=True)
for attr in attrs:
if attr == publish.config.identifier:
continue
try:
value = cmds.getAttr(objset + "." + attr)
except:
continue
# Allow name to be overriden via attribute.
if attr == 'name':
instance.name = value
continue
instance.config[attr] = value
context.add(instance)