Does anyone know of a way to exclude sets of nodes from cached playback? I'm trying to add support for a suite of tools for Maya 2022 and higher, and I'll need to either have frame caching off by default for the whole project, or find a way to have frame caching ignore given sets of nodes. I'd like to leave the option open to the animators to use Frame Caching if possible, has anyone experimented with this?
- Many thanks
Hi!
I looked into this a while back, when I wanted to see if I could exclude a specific dynamic part of my rig from cached playback.
The command cmds.cacheEvaluator seems to allow the exclusion of specific nodes by using the Built-in Action "disableEvaluationCache" but the problem with this command is, that the Built-in filters are very limited.
I found this documentation:
Which seems to imply that you can use the API Class "MPxCacheConfigRuleFilter" to create custom filters for the command. But sadly I could not find any examples of this class being used and no documentation on it outside of the C++ API, which I'm not familiar with.
So that was where I decided that for my purposes it wasn't worth looking into this any further, and I just created a read me that told animators to just have cached Playback turned off when animating the dynamic parts.
I still thought I'd mention it, maybe this is a good starting point for you. If you find a solution, I would be thrilled to hear how you achieved it.
I hope it helps!
I've got to put a pin in this for now because I don't know C++ yet. Here's how far I've gotten with the help of AI and the docs - seems like there's a way to do it - the key, as usual, is to believe in ourselves.
import maya.OpenMayaMPx as OpenMayaMPx
import maya.api.OpenMaya as OpenMaya
import maya.cmds
import timeFilter
"""
# something in this??
import maya.plugin.evaluator.CacheEvaluatorManager
maya.plugin.evaluator.CacheEvaluatorManager.CACHE_STANDARD_MODE_EVAL.insert(0, CacheConfigRuleFilter)
maya.plugin.evaluator.CacheEvaluatorManager.TODO()
dir(maya.plugin.evaluator.CacheEvaluatorManager)
"""
class CacheConfigRuleFilter(OpenMayaMPx.MPxCacheConfigRuleFilter):
def __init__(self):
super(CacheConfigRuleFilter, self).__init__()
def isMatch(self, evalNode):
# Check if the node is connected to a node called "timeFilter"
if timeFilter.IsFiltered("evalNode"):
return True
return False
cmds.cacheEvaluator("pCube1", query=True, cacheName="evaluation")
def registerCustomFilter():
# Create an instance of the custom caching rule filter
customFilter = CacheConfigRuleFilter()
# Register the custom filter with the cache configuration system
# registry = OpenMaya.MCacheConfigRuleRegistry.getInstance() <- No
# registry.addCustomRuleFilter(customFilter) < - ??
# registry.registerFilter("custom", customFilter)
def applyCustomCacheConfigRuleFilter():
# Apply the custom filter using cmds.cacheEvaluator command
maya.cmds.cacheEvaluator(
newFilter='custom',
newFilterParam='',
newAction='disableEvaluationCache'
)
Can't find what you're looking for? Ask the community or share your knowledge.