Advertisement
Dieton

vrchat and iphone face blender shape key namer.py

Jul 30th, 2024 (edited)
263
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 4.26 KB | Software | 0 0
  1. """
  2. all this dose is create blenshapes with the appropritae name for there situation
  3.  
  4. iPhone Ar Face Motion capture Blendshapes
  5.        # Predefined list of shape key names
  6.        names = [
  7.            "Basis", "browOuterUp_L", "browOuterUp_R", "eyeSquint_L", "eyeSquint_R",
  8.            "eyeLookIn_L", "eyeLookOut_L", "eyeLookIn_R", "eyeLookOut_R", "eyeLookUp_L",
  9.            "eyeLookUp_R", "eyeLookDown_L", "eyeLookDown_R", "cheekPuff", "cheekSquint_L",
  10.            "cheekSquint_R", "noseSneer_L", "noseSneer_R", "mouthLeft", "mouthRight",
  11.            "mouthPucker", "mouthFunnel", "mouthSmile_L", "mouthSmile_R", "mouthFrown_L",
  12.            "mouthFrown_R", "mouthDimple_L", "mouthDimple_R", "mouthPress_L", "mouthPress_R",
  13.            "mouthShrugLower", "mouthShrugUpper", "mouthStretch_L", "mouthStretch_R",
  14.            "mouthUpperUp_L", "mouthUpperUp_R", "mouthLowerDown_L", "mouthLowerDown_R",
  15.            "mouthRollUpper", "mouthRollLower", "mouthClosed", "jawForward", "jawOpen",
  16.            "jawLeft", "jawRight", "browInnerUp", "eyeBlinking_Right", "eyeBlinking_Left",
  17.            "browDown_Left", "browDown_Right", "eyeWide_Right", "eyeWide_Left",
  18.            "tongue_jawOpen", "tongue_jawForward", "tongue_jawLeft", "tongue_jawRight",
  19.            "tongue_tongueOut"
  20.        ]
  21.        
  22. Vrchat Defult Facial Bland shapes
  23.        # Predefined list of shape key names
  24.        names = [
  25.            "Basis", "blink_both", "blink_left", "blink_righ", "lowerlid_left", "lowerlid_tight",
  26.            "v_th", "v_ss", "v_sil", "v_rr", "v_pp", "v_ou", "v_oh", "v_nn", "v_kk", "v_ih", "v_ff", "v_ee", "v_dd", "v_ch", "v_aa",
  27.            "button-out", "mouth-open", "mouth-smile"
  28.        ]
  29. """
  30.  
  31. import bpy
  32.  
  33. def apply_shape_keys_from_list():
  34.     # Get the active object
  35.     active_object = bpy.context.active_object
  36.  
  37.     # Check if an object is selected and is in Object mode
  38.     if active_object and active_object.type == 'MESH' and bpy.context.mode == 'OBJECT':
  39.         # Ensure the mesh has an armature modifier
  40.         armature_modifier = active_object.modifiers.get("Armature")
  41.         if not armature_modifier:
  42.             print("Error: Please select a mesh with an Armature modifier.")
  43.             return
  44.  
  45.         # Predefined list of shape key names
  46.         names = [
  47.             "Basis", "browOuterUp_L", "browOuterUp_R", "eyeSquint_L", "eyeSquint_R",
  48.             "eyeLookIn_L", "eyeLookOut_L", "eyeLookIn_R", "eyeLookOut_R", "eyeLookUp_L",
  49.             "eyeLookUp_R", "eyeLookDown_L", "eyeLookDown_R", "cheekPuff", "cheekSquint_L",
  50.             "cheekSquint_R", "noseSneer_L", "noseSneer_R", "mouthLeft", "mouthRight",
  51.             "mouthPucker", "mouthFunnel", "mouthSmile_L", "mouthSmile_R", "mouthFrown_L",
  52.             "mouthFrown_R", "mouthDimple_L", "mouthDimple_R", "mouthPress_L", "mouthPress_R",
  53.             "mouthShrugLower", "mouthShrugUpper", "mouthStretch_L", "mouthStretch_R",
  54.             "mouthUpperUp_L", "mouthUpperUp_R", "mouthLowerDown_L", "mouthLowerDown_R",
  55.             "mouthRollUpper", "mouthRollLower", "mouthClosed", "jawForward", "jawOpen",
  56.             "jawLeft", "jawRight", "browInnerUp", "eyeBlinking_Right", "eyeBlinking_Left",
  57.             "browDown_Left", "browDown_Right", "eyeWide_Right", "eyeWide_Left",
  58.             "tongue_jawOpen", "tongue_jawForward", "tongue_jawLeft", "tongue_jawRight",
  59.             "tongue_tongueOut"
  60.         ]
  61.  
  62.         # Set the frame range based on your animation
  63.         start_frame = bpy.context.scene.frame_start
  64.         end_frame = bpy.context.scene.frame_end
  65.  
  66.         # Iterate over each frame
  67.         for frame in range(start_frame, end_frame + 1):
  68.             # Set the current frame
  69.             bpy.context.scene.frame_set(frame)
  70.  
  71.             # Apply the armature modifier as a shape key
  72.             bpy.ops.object.modifier_apply_as_shapekey(keep_modifier=True, modifier="Armature")
  73.  
  74.             # Assign a name from the list to the new shape key
  75.             shape_key_name = names[frame % len(names)]
  76.             active_object.data.shape_keys.key_blocks[-1].name = shape_key_name
  77.  
  78.         print("Shape keys applied and named from the list.")
  79.     else:
  80.         print("Error: Please select a mesh object in Object mode.")
  81.  
  82. # Call the function to apply shape keys and assign names
  83. apply_shape_keys_from_list()
  84.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement