mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-26 22:02:15 +01:00
Improve speed of Collect History logic
- maya.cmds.listHistory returns duplicates if multiple nodes have the same node in histor, thus making them unique reduces tons of items continuing through all the commands - cmds.ls(type="renderLayer") now without input nodes. History tends to be so big that calling the command with those nodes as arguments produces a big overhead, simultaneously amount of renderlayers usually tend to be relatively small. So we just get all renderlayers and filter ourselves. - use `fastIteration` flag in Maya 2020+
This commit is contained in:
parent
b2d6011d21
commit
fdd7efb2bf
1 changed files with 15 additions and 8 deletions
|
|
@ -22,15 +22,22 @@ class CollectMayaHistory(pyblish.api.InstancePlugin):
|
|||
|
||||
def process(self, instance):
|
||||
|
||||
# Collect the history with long names
|
||||
history = cmds.listHistory(instance, leaf=False) or []
|
||||
history = cmds.ls(history, long=True)
|
||||
kwargs = {}
|
||||
if int(cmds.about(version=True)) >= 2020:
|
||||
# New flag since Maya 2020 which makes cmds.listHistory faster
|
||||
kwargs = {"fastIteration": True}
|
||||
else:
|
||||
self.log.debug("Ignoring `fastIteration` flag before Maya 2020..")
|
||||
|
||||
# Remove invalid node types (like renderlayers)
|
||||
invalid = cmds.ls(history, type="renderLayer", long=True)
|
||||
if invalid:
|
||||
invalid = set(invalid) # optimize lookup
|
||||
history = [x for x in history if x not in invalid]
|
||||
# Collect the history with long names
|
||||
history = set(cmds.listHistory(instance, leaf=False, **kwargs) or [])
|
||||
history = cmds.ls(list(history), long=True)
|
||||
|
||||
# Exclude invalid nodes (like renderlayers)
|
||||
exclude = cmds.ls(type="renderLayer", long=True)
|
||||
if exclude:
|
||||
exclude = set(exclude) # optimize lookup
|
||||
history = [x for x in history if x not in exclude]
|
||||
|
||||
# Combine members with history
|
||||
members = instance[:] + history
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue