Advertisement
Bagserk

Rename Shapekeys

Apr 24th, 2019
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.57 KB | None | 0 0
  1. import bpy
  2.  
  3. from mathutils import Vector, Matrix, Quaternion, Euler, Color
  4.  
  5. context = bpy.context
  6.  
  7. #start list with first item as 'Basis'
  8. poseList = ['Basis']
  9.      
  10. #Get list of names from pose library
  11. rig = bpy.data.objects.get("Face_Armature")
  12. pl = rig.pose_library
  13. i = 1
  14. if pl != None:
  15.     for item in pl.pose_markers:
  16.         poseList.append(item.name)
  17.         print("Pose " + poseList[i] + " appended to list successfully")
  18.         i+=1
  19.  
  20. #prepare variables for next step
  21. i = 0
  22.  
  23. #suffix for names
  24. suffix = ""
  25.  
  26. #prefix for names
  27. prefix = ""
  28.  
  29. #set prefix and suffix based on object's name
  30. for dest in bpy.context.selected_objects:    
  31.     if "head" in dest.name:
  32.         prefix = "bs00_eye."        
  33.         suffix = ""
  34.     elif "brows" in dest.name:
  35.         prefix = "bs02_mayuge."
  36.         suffix = "_mu"
  37.     elif "lashes" in dest.name:
  38.         prefix = "bs01_matuge."
  39.         suffix = "_m"
  40.     elif "tongue" in dest.name:
  41.         prefix = "bs07_sita."
  42.         suffix = "_sita"
  43.     elif "teeth" in dest.name:
  44.         prefix = "bs06_ha."
  45.         suffix = "_ha"
  46.     elif "t1" in dest.name:
  47.         prefix = "bs03_namida01."
  48.         suffix = "_n01"
  49.     elif "t2" in dest.name:
  50.         prefix = "bs04_namida02."
  51.         suffix = "_n02"
  52.     #get shape keys
  53.     sks = dest.data.shape_keys
  54.     #get shape keys names
  55.     skNames = sks.key_blocks
  56.     #cycle through destination's shapekeys and rename based on all previous rules
  57.     for sk in skNames:
  58.         if sk.name != "Basis":
  59.             sk.name = prefix + poseList[i] + suffix + "_0"
  60.         i +=1
  61.     i = 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement