sorting instances based on fammily, sorting renderlayers based on display order

This commit is contained in:
aardschok 2018-01-08 14:00:36 +01:00
parent c81b18aeb1
commit 4f3fc41b74
2 changed files with 17 additions and 2 deletions

View file

@ -113,7 +113,11 @@ class CollectInstances(pyblish.api.ContextPlugin):
# user interface interested in visualising it.
self.log.info("Found: \"%s\" " % instance.data["name"])
context[:] = sorted(context)
# Sort/grouped by family (preserving local index)
grouped = sorted(enumerate(context), key=self.sorter)
context[:] = [x[1] for x in grouped]
# context[:] = sorted(context, key= lambda x: (x.data['families'],
# x.data['name']))
return context
@ -134,3 +138,10 @@ class CollectInstances(pyblish.api.ContextPlugin):
parents.extend(items)
return list(set(parents))
def sorter(self, x):
"""Sort a tuple of index and instance"""
index, instance = x
family = instance.data.get("families", instance.data.get("family"))
return family, index

View file

@ -12,7 +12,6 @@ class CollectMayaRenderlayers(pyblish.api.ContextPlugin):
order = pyblish.api.CollectorOrder
hosts = ["maya"]
label = "Render Layers"
optional = True
def process(self, context):
@ -39,6 +38,11 @@ class CollectMayaRenderlayers(pyblish.api.ContextPlugin):
cmds.getAttr("{}.renderable".format(i)) and not
cmds.referenceQuery(i, isNodeReferenced=True)]
# Sort by displayOrder
renderlayers = sorted(renderlayers,
key=lambda x: -cmds.getAttr("%s.displayOrder" % x))
renderlayers = reversed(renderlayers)
if not use_defaultlayer:
renderlayers = [i for i in renderlayers if
not i.endswith("defaultRenderLayer")]