pyblish / pyblish-qml

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

Instance "category" group can get doubled if collecting one, another, then back to the first. #310

Closed darkvertex closed 5 years ago

darkvertex commented 5 years ago

I noticed that there seems to be a bug where a "category" section may get recreated if not continuously creating instances under that same category.

In other words, make some for category A, make some B, then make some for A again and those will have a new group in the UI despite one already existing from before.

Here's some dummy collectors that show you the problem:

import pyblish.api

class DummyCollector1(pyblish.api.ContextPlugin):
    order = pyblish.api.CollectorOrder
    def process(self, context):
        for i in range(1,4):
            context.create_instance('potato_%s' % i, category='Fries')

class DummyCollector2(pyblish.api.ContextPlugin):
    order = pyblish.api.CollectorOrder
    def process(self, context):
        for i in range(1,4):
            context.create_instance('carrot_%s' % i, category='Carrots')

class DummyCollector3(pyblish.api.ContextPlugin):
    order = pyblish.api.CollectorOrder
    def process(self, context):
        for i in range(1,4):
            context.create_instance('yam_%s' % i, category='Fries')

Gives me this: image Notice how "Fries" exists twice. I'd have expected it to reuse the first group.

davidlatwe commented 5 years ago

It seems to be related to an intentional feature:

The instances are displayed in the order they are processed, and it's a feature of Pyblish to be able to arrange (and re-arrange) the instance order inside the context.

Quote from here

darkvertex commented 5 years ago

Okay! If it's intentional, then I'll shuffle around my plugins to accommodate. No worries.

tokejepsen commented 5 years ago

A bit late on this, but you can also rearrange the instances based their category, with a plugin at the end of the collection stage.

darkvertex commented 5 years ago

How would that work? How does one reorder an Instance after creation?

On Mon, Nov 19, 2018, 8:19 AM Toke Jepsen notifications@github.com wrote:

A bit late on this, but you can also rearrange the instances based their category, with a plugin at the end of the collection stage.

— You are receiving this because you modified the open/close state.

Reply to this email directly, view it on GitHub https://github.com/pyblish/pyblish-qml/issues/310#issuecomment-439889889, or mute the thread https://github.com/notifications/unsubscribe-auth/AA5dE0DfjQ0aere46SR2KAG2qTis-3ZTks5uwq_tgaJpZM4YLFnj .

tokejepsen commented 5 years ago

This is an old example for sorting the instances by family and name, but you can probably adapt it for category:

https://forums.pyblish.com/t/solved-collection-sorting/189