Advertisement
Guest User

Flip Axis on Bones in Blender

a guest
Nov 24th, 2015
260
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.87 KB | None | 0 0
  1. import bpy
  2. import mathutils
  3.  
  4. ob = bpy.context.object
  5. sce = bpy.context.scene
  6.  
  7. if ob.type == 'ARMATURE':
  8.     armature = ob.data
  9.  
  10.     pose = sce.objects.active.pose
  11.  
  12.     for bone in armature.bones:
  13.         if "spine" in bone.name or "neck" in bone.name or "head" in bone.name or "pelvis" in bone.name:
  14.             print(bone.name , " : " , bone.vector.x)
  15.              
  16.             boneRot = pose.bones[bone.name].rotation_quaternion.to_euler()
  17.             print(pose.bones[bone.name].rotation_quaternion)
  18.             print(boneRot)
  19.            
  20.            
  21.             #Comment/Uncomment to select Axis to flip
  22.             #X-Axis
  23.             boneRot[0] *= -1
  24.             #Y-Axis
  25.             boneRot[1] *= -1
  26.             #Z-Axis
  27.             boneRot[2] *= -1
  28.             print(boneRot)
  29.             pose.bones[bone.name].rotation_quaternion = boneRot.to_quaternion()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement