need ops.transform.rotate for arm bone relative to spine

Scripting in Blender with Python, and working on the API

Moderators: jesterKing, stiv

wretch1958
Posts: 22
Joined: Thu Mar 29, 2012 6:26 am

need ops.transform.rotate for arm bone relative to spine

Postby wretch1958 » Tue Oct 16, 2012 7:39 pm

Code: Select all

def rotBone(name, degree):
   bpy.ops.object.mode_set(mode="POSE")
   bpy.ops.pose.select_all(action="DESELECT")
   bpy.data.armatures["Armature"].bones[name].select = True
   bpy.ops.transform.rotate(value=(degree,), axis = (0,1,0))
   bpy.ops.pose.select_all(action="DESELECT")

I am trying to programmatically create a walk or run cycle. If the character, in POSE mode, starts at attention, the above method will, let's say, rotate the arm bone (name="arm_L.001", degree = .7) forward as if to shake hands. Then I can make the right leg step forward as well etc.... But the axis ("y" in this case) seems to be relative to the scene, not to the parent bone ("spine"). If before rotating arm I rotate the spine, then y rotation of arm still follows previous motion, does not adjust for turning of spine, so arm now comes out sideways rather than forward.

Is there a way to specify arm/leg bone rotation relative to the parent bone (spine), so if spine twists the arm movement stays same relative to the spine? Do I have to rotate the scene "z" axis manually after rotating the spine?

CoDEmanX
Posts: 894
Joined: Sun Apr 05, 2009 7:42 pm
Location: Germany

Postby CoDEmanX » Tue Oct 30, 2012 3:16 pm

not sure if this is what you mean:

- select the arm/leg bone in posemode
- go to Bone tab, untick "Inherit Rotation"
- rotate spine, arm/leg bone will keep it's orientation (like a vector), but changes it's location
I'm sitting, waiting, wishing, building Blender in superstition...

CoDEmanX
Posts: 894
Joined: Sun Apr 05, 2009 7:42 pm
Location: Germany

Postby CoDEmanX » Tue Oct 30, 2012 3:28 pm

just realized, that you may not enable it afterwards again, even if you keyframed poses, it will change

you may look into Constraints
I'm sitting, waiting, wishing, building Blender in superstition...


Return to “Python”

Who is online

Users browsing this forum: No registered users and 0 guests