pyblish / pyblish-qml

Pyblish QML frontend for Maya 2013+, Houdini 11+, Nuke 8+ and more
GNU Lesser General Public License v3.0
114 stars 44 forks source link

Implementing #302, Instances' visual category #303

Closed davidlatwe closed 6 years ago

davidlatwe commented 6 years ago

Thought this feature(#302) is interesting, did a quick implementation for try out.

qml_category

Plugins:

Example Code ```python import pyblish.api instances = { "Batman": { "family": "hero.human", "category": "Justice League", }, "Superman": { "family": "hero.alien", "category": "Justice League", }, "Spiderman": { "family": "hero.mutant", "category": "Avengers", }, "Ironman": { "family": "hero.human", "category": "Avengers", }, "David": { "family": "hero.human", }, "Wolverine": { "family": "hero.mutant", }, "E.T.": { "family": "hero.alien", }, } class CollectInstances(pyblish.api.ContextPlugin): order = pyblish.api.CollectorOrder def process(self, context): for name, data in instances.items(): instance = context.create_instance(name) instance.data.update(data) context[:] = sorted(context, key=lambda inst: inst.data.get("category", "")) return context class ListInstances(pyblish.api.ContextPlugin): order = pyblish.api.CollectorOrder + 0.1 def process(self, context): for instance in context: self.log.info(instance) class ValidateMutant(pyblish.api.InstancePlugin): order = pyblish.api.ValidatorOrder families = ["hero.mutant"] def process(self, instance): return True class ValidateHuman(pyblish.api.InstancePlugin): order = pyblish.api.ValidatorOrder families = ["hero.human"] def process(self, instance): return True class ValidateAlien(pyblish.api.InstancePlugin): order = pyblish.api.ValidatorOrder families = ["hero.alien"] def process(self, instance): return True pyblish.api.register_plugin(CollectInstances) pyblish.api.register_plugin(ListInstances) pyblish.api.register_plugin(ValidateMutant) pyblish.api.register_plugin(ValidateHuman) pyblish.api.register_plugin(ValidateAlien) ```
darkvertex commented 6 years ago

Looks great, @davidlatwe! Exactly what I wanted. :)

@mottosso: What do you think?

davidlatwe commented 6 years ago

Thanks guys :D Let me check a bit and bump the version !

davidlatwe commented 6 years ago

Version bumped :) Will merge and release later today !