Hi!
I am more of an animator/modeller and starting to explore the Python API in Blender.
I have been reading Jason Osipa’s “Stop Staring - Facial Modeliing and Animation Done Right”. Along the way, I am adapting some of the techniques done with Maya (that’s what the author uses) into my Blender workflow. Along the way, I also manage to adapt some Maya Mel scripts by using modifiers, drivers and seldom some fairly simple scripts. However I got stuck trying to translate one Mel Script.
The script basically picks the selected shape key and creates three new partial copies of it. In the first copy, we have the shape key animation along the X axis. On the second copy we have shape key animation along the Y axis. The third one is the animation along the Z action. I hope I was clear on this.
So far I made this:
import bpy
scene = bpy.context.scene
obj = scene.objects.active
shape_index = bpy.context.object.active_shape_key_index
bpy.ops.object.shape_key_add(from_mix=True)
bpy.ops.object.shape_key_add(from_mix=True)
bpy.ops.object.shape_key_add(from_mix=True)
#do something here
bpy.context.object.active_shape_key_index = bpy.context.object.active_shape_key_index - 2
#do something here
bpy.context.object.active_shape_key_index = bpy.context.object.active_shape_key_index + 1
#do something here
The idea is to create the copies, and delete the axes that will not be used in each one of them.
I also looked into the bmesh module API to find some command that could delete the animation in each axis, like we can do in the graph editor, but I did not find anything. Maybe I am using a wrong approach to this problem. :mad:
As a sidenote, I am also planning to give a name to each copy, for example “_X”, “_Y”, “_Z”, but still have not found a way to do that.
I tried to assign a var to bpy.context.object.active_shape_key_index object , so I don’t have to write all of it while I am scripting, but somehow the script ceases to select the shape keys if I do that. :mad:
My plan is to turn this into an addon later, right now I prefer to focus on funtionality.
Can anyone help me with this one?
Thanks! :o