I will be resurrecting this thread because I just started programming the script since I recently started learning python.
So far this is what I have:
import bpy
get name/location info on active pose bone
obj = bpy.context.active_pose_bone.name
loc = bpy.context.active_pose_bone.matrix.to_translation()
create control object
bpy.ops.curve.primitive_bezier_circle_add(view_align=False, enter_editmode=False, location=(loc), layers=(True, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False))
copy rotation of active pose bone to controller object
bpy.ops.object.constraint_add(type=‘COPY_ROTATION’)
bpy.context.object.constraints[“Copy Rotation”].target = bpy.data.objects[“Armature”]
bpy.context.object.constraints[“Copy Rotation”].subtarget = obj
bpy.ops.object.visual_transform_apply()
bpy.ops.object.constraints_clear()
convert controller object to MESH
bpy.ops.object.convert(target=‘MESH’)
move controller object to layer 2
bpy.ops.object.move_to_layer(layers=(False, True, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False))
rename controller object
bpy.context.object.name = “CTRL_%s” % obj
make custom shape on active pose bone
bpy.context.object.pose.bones["%s" % obj].custom_shape = bpy.data.objects[“CTRL_%s” % obj]
bpy.context.object.pose.bones[“Index02.L”].use_custom_shape_bone_size = False
bpy.context.object.data.bones[“Index02.L”].show_wire = True
I am having some issues with the last part of the script.
how do I activate the armature again so that I can connect the custom shape to the pose bone? after creating the controller object and renaming, blender can’t find the pose bones of the armature because (as I read it) the armature is no longer active.
Am I misunderstanding this? how can I make this work?
thank you