script to automate create symmetric armature bones

Scripting in Blender with Python, and working on the API

Moderators: jesterKing, stiv

Post Reply
wretch1958
Posts: 0
Joined: Thu Mar 29, 2012 6:26 am

script to automate create symmetric armature bones

Post by wretch1958 » Tue May 08, 2012 7:29 am

Would like to automate with script creation of armature bones, but with following code cannot simply run:
buildArmature()
build2()
#need to grab tail, move slightly so left side shows
build3()
#need to grab tail, move slightly so left side shows
build4()
#need to grab tail, move slightly so left side shows

need to manually tweek or move just a little the armature (selected tail bone) after build2, after build3, and after build4 to make the mirrored bones show, otherwise mirror does not show and the end result is wrong and not symmetric. Any way to avoid having to manually force the symmetry? If i could avoid this, build2,3,4 could be put into a loop and the whole thing could run without manual intervention.

Code: Select all

def build2():
	bpy.ops.armature.select_all(action="DESELECT")
	bpy.context.object.data.edit_bones['Bone'].select_tail = True
	bpy.ops.armature.extrude_forked(ARMATURE_OT_extrude={"forked":False}, 
	 TRANSFORM_OT_translate={"value":(1, 0, 0),"constraint_axis":(False, False, False), 
	  "constraint_orientation":'GLOBAL', "mirror":False, "proportional":'DISABLED', 
	   "proportional_edit_falloff":'SMOOTH', "proportional_size":1, 
		"snap":False, "snap_target":'CLOSEST', "snap_point":(0, 0, 0), "snap_align":False, 
		 "snap_normal":(0, 0, 0), "texture_space":False, 
		  "release_confirm":False})

def build3():
	bpy.ops.armature.select_all(action="DESELECT")
	bpy.context.object.data.edit_bones['Bone_R'].select_tail = True
	bpy.ops.armature.extrude_forked(ARMATURE_OT_extrude={"forked":False}, 
	 TRANSFORM_OT_translate={"value":(0, 0, -.5),"constraint_axis":(False, False, False), 
	  "constraint_orientation":'GLOBAL', "mirror":False, "proportional":'DISABLED', 
	   "proportional_edit_falloff":'SMOOTH', "proportional_size":1, 
		"snap":False, "snap_target":'CLOSEST', "snap_point":(0, 0, 0), "snap_align":False, 
		 "snap_normal":(0, 0, 0), "texture_space":False, 
		  "release_confirm":False})

def build4():
	bpy.ops.armature.select_all(action="DESELECT")
	bpy.context.object.data.edit_bones['Bone_R.001'].select_tail = True
	bpy.ops.armature.extrude_forked(ARMATURE_OT_extrude={"forked":False}, 
	 TRANSFORM_OT_translate={"value":(0, 0, -.5),"constraint_axis":(False, False, False), 
	  "constraint_orientation":'GLOBAL', "mirror":False, "proportional":'DISABLED', 
	   "proportional_edit_falloff":'SMOOTH', "proportional_size":1, 
		"snap":False, "snap_target":'CLOSEST', "snap_point":(0, 0, 0), "snap_align":False, 
		 "snap_normal":(0, 0, 0), "texture_space":False, 
		  "release_confirm":False})

def buildArmature():
	bpy.ops.object.armature_add(view_align=False, enter_editmode=False, location=(0, 0, -0.5), 
	  rotation=(0, 0, 0), layers=(True, False, False, False, True, False, False, False, False, False, 
	    False, False, False, False, False, False, False, False, False, False))
	bpy.ops.transform.translate(value=(0, 0, -0.458134), constraint_axis=(False, False, True), constraint_orientation='GLOBAL', 
	  mirror=False, proportional='DISABLED', proportional_edit_falloff='SMOOTH', proportional_size=1, snap=False, 
	    snap_target='CLOSEST', snap_point=(0, 0, 0), snap_align=False, snap_normal=(0, 0, 0), texture_space=False, 
		  release_confirm=False)
	bpy.ops.object.mode_set(mode='EDIT')
	bpy.data.armatures["Armature"].use_mirror_x = True

Post Reply