Python API: How do I link an alembic cache file to the Mesh Sequence Cache Modifier?

Hey everyone!

I’m trying to write a small Add-On that automatically adds a Mesh Sequence Cache Modifer to all selected objects with the corresponding alembic cache already loaded in the Modifier. So if you have an asset that consists of many objects, with one click you can load a cache for every object.

For that matter I need to link the alembic cache file, which i import via bpy.ops.cachefile.open() to the Mesh Sequence Cache Modifier.
It seems like for every thing in the modifier there is function in the PythonAPI except for that one! Also If I manually link or unlink the alembic file to the modifier nothing happens in the console!

Does anybody know how to link the alembic file to the Mesh Sequence Cache Modifier via PythonAPI?

Wish you all a great week !

Paul

Can you share some code of what you’ve got?

There doesn’t seem to be a way to load a cache file directly via bpy.data.cache_files. So there’s only bpy.ops.cachefile.open(filepath=myabcpath).
Once loaded you can fetch the cache object from bpy.data.cache_files.get("myabcname")
This cache object can then be handed over to the mod via mycachemod.cache_file

Mind you, I have never worked with this and so can’t really test it. but I could load an empty file called cache.abc and have successfully added it to the mod from the console.

hey man! i just tried exactly what you described and it worked like a charm! thank you so much :slight_smile: I wasn’t aware of the .cache_file property of the modifier! if I assign this to my cache which I fetch via bpy.data.cache_files.get(“myabcname”) as you said, it works just great! You made my day haha. Have a good one!

1 Like