Posted: Mon Oct 29, 2012 9:15 am
Joined: 09 Oct 2012
Posts: 16
Hi,
Can anyone help me how to move two bones closer or farther using python script?
thanks.
Posted: Mon Oct 29, 2012 1:56 pm
Joined: 05 Apr 2009
Posts: 699
Bones, EditBones or PoseBones?
_________________
I'm sitting, waiting, wishing, building Blender in superstition...
Posted: Mon Oct 29, 2012 6:34 pm
Joined: 09 Oct 2012
Posts: 16
Edit bones...
Thanks in advance
Posted: Tue Oct 30, 2012 8:35 am
Joined: 05 Apr 2009
Posts: 699
you need to be in edit mode to have edit_bones available:
| Code: |
# should check here for context.object, 'cause mode_set will fail if it's None
# Or set new selected/active ob
bpy.ops.object.mode_set(mode='OBJECT', toggle=False)
# move first editbone's head of 'Armature' by 1 unit on x-axis
bpy.data.armatures['Armature'].edit_bones[0].head.x += 1 |
So it's EditBone.head and EditBone.tail
_________________
I'm sitting, waiting, wishing, building Blender in superstition...
Posted: Thu Nov 01, 2012 7:13 am
Joined: 09 Oct 2012
Posts: 16
Hi,
I want to move both bones closer or farther at the same time. Its not that one bone is stationary and you can move other.
Thanks.
Posted: Thu Nov 01, 2012 10:10 am
Joined: 05 Apr 2009
Posts: 699
you can change how many bones you want, e.g.
| Code: |
bpy.data.armatures['Armature'].edit_bones[0].head.x += 1
bpy.data.armatures['Armature'].edit_bones[1].head.x += 1
bpy.data.armatures['Armature'].edit_bones[0].tail +=(1.5, -0.5, 1)
|
but you may look into Constraints if you wanna let one bone move when the other moves.
_________________
I'm sitting, waiting, wishing, building Blender in superstition...