What’s wrong with writing this function in your Lua script?
function replaceObject(object, newMesh) newObject = loadMesh(newMesh) setPosition(newObject, getPosition(object)) setRotation(newObject, getRotation(object)) setScale(newObject, getScale(object)) updateMatrix(newObject) deleteObject(object) return newObject end
Then you could also set an animation as you suggested.
I think this function should reside in your personal code and not in the C++ core engine since it’s only using already available functionality. You can of course package your script as library and distribute it for others to use. That is the preferred way of getting this function to the public.