diff --git a/openpype/hosts/maya/plugins/publish/collect_history.py b/openpype/hosts/maya/plugins/publish/collect_history.py index 16c8e4342e..71f0169971 100644 --- a/openpype/hosts/maya/plugins/publish/collect_history.py +++ b/openpype/hosts/maya/plugins/publish/collect_history.py @@ -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