Created
August 2, 2023 00:54
-
-
Save nmfisher/4e92efb4be3700a1fde75d455e3462a6 to your computer and use it in GitHub Desktop.
Generate shape keys from frame poses in Blender
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# this assumes that every 10th frame is the pose corresponding to the shape key, ordered according to the variable arkit | |
# adjust frame_increment if this isn't correct (e.g. if each pose is on consecutive frames, set frame_increment to 1) | |
# reorder arkit to match the order of poses in your action if needed | |
# select the mesh in the viewport, then run this script | |
import bpy | |
rig_name="rig" | |
frame = -1 | |
frame_increment = 10 | |
arkit=["browInnerUp","browDownLeft","browDownRight","browOuterUpLeft","browOuterUpRight","eyeLookUpLeft","eyeLookUpRight","eyeLookDownLeft","eyeLookDownRight","eyeLookInLeft","eyeLookInRight","eyeLookOutLeft","eyeLookOutRight","eyeBlinkLeft","eyeBlinkRight","eyeSquintRight","eyeSquintLeft","eyeWideLeft","eyeWideRight","cheekPuff","cheekSquintLeft","cheekSquintRight","noseSneerLeft","noseSneerRight","jawOpen","jawForward","jawLeft","jawRight","mouthFunnel","mouthPucker","mouthLeft","mouthRight","mouthRollUpper","mouthRollLower","mouthShrugUpper","mouthShrugLower","mouthClose","mouthSmileLeft","mouthSmileRight","mouthFrownLeft","mouthFrownRight","mouthDimpleLeft","mouthDimpleRight","mouthUpperUpLeft","mouthUpperUpRight","mouthLowerDownLeft","mouthLowerDownRight","mouthPressLeft","mouthPressRight","mouthStretchLeft","mouthStretchRight"] | |
for key in arkit: | |
frame += frame_increment | |
bpy.context.scene.frame_set(frame) | |
bpy.ops.object.modifier_apply_as_shapekey(keep_modifier=True,modifier=rig_name) | |
bpy.context.object.data.shape_keys.key_blocks["rig"].name = key | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment