SHARE
TWEET

Flip Axis on Bones in Blender

a guest Nov 24th, 2015 183 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top