getavalon / core

The safe post-production pipeline - https://getavalon.github.io/2.0
MIT License
213 stars 48 forks source link

Scene Inventory action selection cannot pass into other actions #536

Closed davidlatwe closed 4 years ago

davidlatwe commented 4 years ago

What happened ?

When running inventory action that selects items from process result, although the selection is visually correct (rows get highlighted), but other actions like "Remove items" can only get one item from selection (the item which has mouse clicked) to process.

What did you expect ?

Items that selected (highlighted) by action should be able to pass into other actions.

To Reproduce

  1. Register following inventory action

    import avalon.api
    import avalon.maya
    from maya import cmds
    
    class SelectFromScene(avalon.api.InventoryAction):
    
        label = "Select From Scene"
        icon = "hand-o-up"
    
        @staticmethod
        def is_compatible(container):
            return True
    
        def process(self, containers):
            containers = avalon.maya.ls()
            container_names = set(c["objectName"] for c in containers)
    
            selected = cmds.ls(sl=True)
            selected_items = set()
    
            for node in selected:
                if node in container_names:
                    selected_items.add(node)
                    continue
    
                objsets = cmds.listSets(object=node) or []
                for objset in objsets:
                    if objset in container_names:
                        selected_items.add(objset)
                        break
    
            return selected_items
  2. Load multiple subsets into Maya scene
  3. Select random containerized nodes that accross multiple subsets
  4. Open up Scene Inventory and use the above action to select items
  5. Remove action highlighted items and only one item gets detected

Cause

The action select back feature was shipped in commit 2851fd0 from #353, and the implementation only select the first column in the row. 👇

https://github.com/getavalon/core/blob/f8186bf1804aa1bc0ba5471a13f4c86c12428cd1/avalon/tools/sceneinventory/app.py#L253

But scene inventory pass items into action only if the row if fully selected. 👇

https://github.com/getavalon/core/blob/f8186bf1804aa1bc0ba5471a13f4c86c12428cd1/avalon/tools/sceneinventory/app.py#L296

So the bug (unexpected behavior) appears..


I have a fix in my hand now, a PR will be submitted in no time.