Here's a hacky thing that will work with a suffix. Example: Import the bake of your muscles, rename all the baked muscles to have the following suffix:
"_driver", so the baked
r_bicep_tissue_driver for example.
Then execute this:
import maya.cmds as mc
drive_bones_with_blendshapes(mc.ls("*_driver"), 1, 2, "_driver"))
def drive_bones_with_blendshapes(driver_mesh_list, s, e, driver_suffix):
driver_mesh_list - a list of meshes that will drive your bones (usually a bake)
s, e -- int values. the driver blendshapes are keyed on, so bind pose is ensured.
s is where the blendshape is keyed to 0, e is where it is keyed to 1.
usually s is the same as zSolver1.startFrame, and e is zSolver1.startFrame + 1
driver_suffix - a string for lookup. if you're driving r_bicep_tissue with r_bicep_tissue_driver, driver_suffix is "_driver"
for driver_mesh in driver_mesh_list:
driven_mesh = driver_mesh[:len(driver_suffix) * -1]
if mc.objExists(driven_mesh) and mc.objExists(driver_mesh):
if mc.polyEvaluate(driven_mesh, v=True) == mc.polyEvaluate(driver_mesh, v=True):
mc.select([driver_mesh, driven_mesh], r=True)
blendShape = mc.blendShape(n=driven_mesh + '_blendShape')
mc.setKeyframe(blendShape, attribute=driver_mesh, t=s, v=0)
mc.setKeyframe(blendShape, attribute=driver_mesh, t=e, v=1)
print 'Vertex count different between %s and driver' % driven_mesh