diff --git a/colorbleed/plugins/maya/publish/collect_instances.py b/colorbleed/plugins/maya/publish/collect_instances.py index c233341d48..4e565fc679 100644 --- a/colorbleed/plugins/maya/publish/collect_instances.py +++ b/colorbleed/plugins/maya/publish/collect_instances.py @@ -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 diff --git a/colorbleed/plugins/maya/publish/collect_renderlayers.py b/colorbleed/plugins/maya/publish/collect_renderlayers.py index 045ae35bff..f556b99067 100644 --- a/colorbleed/plugins/maya/publish/collect_renderlayers.py +++ b/colorbleed/plugins/maya/publish/collect_renderlayers.py @@ -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")]