mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-26 05:42:15 +01:00
Skip internal sets from maya.cmds.listSets (fix no object matches name) and change list constants to set constants
This commit is contained in:
parent
149fcf9914
commit
eb82abcc72
1 changed files with 12 additions and 11 deletions
|
|
@ -1059,28 +1059,29 @@ def get_related_sets(node):
|
|||
ignore_suffices = ["out_SET", "controls_SET", "_INST", "_CON"]
|
||||
|
||||
# Default nodes to ignore
|
||||
defaults = ["initialShadingGroup", "defaultLightSet", "defaultObjectSet"]
|
||||
defaults = {"initialShadingGroup", "defaultLightSet", "defaultObjectSet"}
|
||||
|
||||
# Ids to ignore
|
||||
ignored = ["pyblish.avalon.instance", "pyblish.avalon.container"]
|
||||
ignored = {"pyblish.avalon.instance", "pyblish.avalon.container"}
|
||||
|
||||
view_sets = get_isolate_view_sets()
|
||||
|
||||
related_sets = cmds.listSets(object=node, extendToShape=False)
|
||||
if not related_sets:
|
||||
sets = cmds.listSets(object=node, extendToShape=False)
|
||||
if not sets:
|
||||
return []
|
||||
|
||||
# Fix 'no object matches name' errors on nodes returned by listSets.
|
||||
# In rare cases it can happen that a node is added to an internal maya
|
||||
# set inaccessible by maya commands, for example check some nodes
|
||||
# returned by `cmds.listSets(allSets=True)`
|
||||
sets = cmds.ls(sets)
|
||||
|
||||
# Ignore `avalon.container`
|
||||
sets = [s for s in related_sets if
|
||||
sets = [s for s in sets if
|
||||
not cmds.attributeQuery("id", node=s, exists=True) or
|
||||
not cmds.getAttr("%s.id" % s) in ignored]
|
||||
|
||||
# Exclude deformer sets
|
||||
# Autodesk documentation on listSets command:
|
||||
# type(uint) : Returns all sets in the scene of the given
|
||||
# >>> type:
|
||||
# >>> 1 - all rendering sets
|
||||
# >>> 2 - all deformer sets
|
||||
# Exclude deformer sets (`type=2` for `maya.cmds.listSets`)
|
||||
deformer_sets = cmds.listSets(object=node,
|
||||
extendToShape=False,
|
||||
type=2) or []
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue