My answer below is possibly a little too involved for what you’re trying to do, but if you find yourself running out of options, here’s how I might approach it.
What this does, is it takes an array of meshes with a matrix for each and outputs exactly what you’d expect; a combined version of all meshes.
If you perform this operation yourself, instead of rely on the menu-item “Combine”, and it may provide you with some additional flexibility. What you need to do is:
Get your two meshes ready
cmds.createNode(“polyUnite”) will get you a “combine” node.
Connect the “outMesh” attribute of both of the cubes into the “inputPoly[0]” and “inputPoly[1]” slots of the polyUnite node
Connect either “matrix” or “worldMatrix” from both of the cubes into the “inputMat[0]” and “inputMat[1]” slots of the polyUnite node
At this point, the meshes are combined, but are not being outputted just yet.
cmds.createNode(“mesh”) will get you a new mesh to store the result in
Connect “output” of polyUnite into “inMesh” of the new mesh.
And viola, you have a new combined mesh being driven by your original meshes. Their keyframed animation will dynamically update the resulting combination and all is well.
Making the connections
If you haven’t worked with connecting nodes before, it can get a little tricky. I typically use Hypershade for these matters, but it’s likely that the newer Node Editor is equally apt. One thing you might encounter however is having trouble connecting to the second slot of inputMat and inputPoly as Maya only creates slots when they are needed. To make Maya allocate these slots for you, you can ask for it.
cmds.getAttr(“polyUnite1.inputMat[1]”)
At that point, the slot will be available for you to connect with.
After some thought, keyframe animation will only affect the transformation of a node, and not it’s shape. So for step 4, make sure you connect “worldMatrix”, and not “matrix” as the latter won’t take into account any animation applied onto the transform.
Unless I mis-read the OP, can’t you just separate the meshes, animate the separated pieces, and then polyUnite() them? In 2015, at least, that worked for both transform and vert animations.
If you have keys on the original mesh as well, you might try duplicating it first, animating the copies, and using the animated recombined mesh as a wrap deformer on the original
@Theodox You are absolutely right. That was totally my fault, I was deleting the history on the mesh after combining and separating (reflex since I didnt want to keep too many extra nodes in the outliner). Thanks for pointing that out!
@marcuso That is really interesting. I didnt realize you could make those types of connections manually. Learn somethin new everyday!