animate1978 / MB-Lab

MB-Lab is a character creation tool for Blender 4.0 and above, based off ManuelBastioniLAB
Other
1.76k stars 308 forks source link

How to Acess Animation Features from Python #328

Open luisarandas opened 3 years ago

luisarandas commented 3 years ago

Hello and good day.

I'm trying to make some experiments with python inside Blender and I want to animate a pre-rigged character of the MB-Lab. I'm trying to rotate the elements generated from the "rig face" option (that work really well in the 3D scene).

If I iterate through all the objects using a for loop and get them in the terminal:

<bpy_struct, Object("wgt_eyes") at 0x7fdcf85edc08> <bpy_struct, Object("wgt_jaw") at 0x7fdcf85ee208> <bpy_struct, Object("wgt_jaw_out") at 0x7fdcf85ee808> <bpy_struct, Object("wgt_lips") at 0x7fdcf85eee08> <bpy_struct, Object("wgt_mouth_chew") at 0x7fdcf85ef408> <bpy_struct, Object("wgt_mouth_closed") at 0x7fdcf85efa08> <bpy_struct, Object("wgt_mouth_horizontal") at 0x7fdcf8621008> <bpy_struct, Object("wgt_mouth_Inflated") at 0x7fdcf8621608> <bpy_struct, Object("wgt_mouth_LowerOut") at 0x7fdcf8621c08> <bpy_struct, Object("wgt_mouth_open_aggr") at 0x7fdcf8622208> <bpy_struct, Object("wgt_mouth_open_half") at 0x7fdcf8622808> <bpy_struct, Object("wgt_mouth_open_O") at 0x7fdcf8622e08> <bpy_struct, Object("wgt_mouth_open_teeth_closed") at 0x7fdcf8623408> <bpy_struct, Object("wgt_mouth_smile") at 0x7fdcf8623a08> <bpy_struct, Object("wgt_mouth_smile_open") at 0x7fdcf867a008> <bpy_struct, Object("wgt_mouth_smile_open_2") at 0x7fdcf867a608> <bpy_struct, Object("wgt_mouthOpenLarge") at 0x7fdcf867ac08> <bpy_struct, Object("wgt_notrile_expansion") at 0x7fdcf867b208> <bpy_struct, Object("wgt_ph_dial") at 0x7fdcf867b808> <bpy_struct, Object("wgt_pupil_dialation") at 0x7fdcf867be08> <bpy_struct, Object("wgt_sneer") at 0x7fdcf867c408> <bpy_struct, Object("wgt_tongue_horizontal") at 0x7fdcf867ca08> <bpy_struct, Object("wgt_tongue_out") at 0x7fdcf86b3008> <bpy_struct, Object("wgt_tongue_out_pressure") at 0x7fdcf86b3608> <bpy_struct, Object("wgt_tongue_tip_up") at 0x7fdcf86b3c08> <bpy_struct, Object("wgt_tongue_vertical") at 0x7fdcf86b4208>

I'm making something like:

bpy.data.objects["wgt_mouth_smile_open"].rotation_euler[0] = math.radians(x_number)

doesn't seem work.

Any suggestions on how to access your animation features from the python API and maybe set a number line for it to automate?

Thanks!

Upliner commented 3 years ago

Here is correct example:

bone = bpy.data.objects["MBLab_skeleton_face_rig.MBlab_bd1611964441.154789"].pose.bones["Expressions_mouthSmile_max_min"]
bone.rotation_mode = "XYZ"
bone.rotation_euler[0] = math.radians(-20)

But it's lot easier just not to use this face rig and drive shape keys directly