add containers to hierarchy

This commit is contained in:
Ondřej Samohel 2022-03-07 17:59:50 +01:00
parent 3697fba453
commit d81da109a7
No known key found for this signature in database
GPG key ID: 02376E18990A97C6

View file

@ -128,9 +128,9 @@ class ReferenceLoader(openpype.hosts.maya.api.plugin.ReferenceLoader):
return new_nodes
def load(self, context, name=None, namespace=None, options=None):
super(ReferenceLoader, self).load(context, name, namespace, options)
container = super(ReferenceLoader, self).load(context, name, namespace, options)
# clean containers if present to AVALON_CONTAINERS
self._organize_containers(self[:])
self._organize_containers(self[:], container[0])
def switch(self, container, representation):
self.update(container, representation)
@ -167,11 +167,11 @@ class ReferenceLoader(openpype.hosts.maya.api.plugin.ReferenceLoader):
)
@staticmethod
def _organize_containers(nodes):
# type: (list) -> None
def _organize_containers(nodes, container):
# type: (list, str) -> None
for node in nodes:
id_attr = "{}.id".format(node)
if not cmds.attributeQuery("id", node=node, exists=True):
continue
if cmds.getAttr(id_attr) == AVALON_CONTAINER_ID:
cmds.sets(node, forceElement=AVALON_CONTAINERS)
cmds.sets(node, forceElement=container)