Replacing a rigged mesh for animation

Hey,

I’ve been trying to write a script to replace the mesh for a rigged character.

There are a couple of solutions to this in the forum already, but they all relate to using the game’s engine. In my case I want to be able to feed the script to Blender to change the mesh and then render the result into an animation.

Is there a way to do this and preserve the rigging?

Thank