I'm trying to create a bone and parent an empty to its tail, and constrain the bone to point toward the camera. See this pastebin. I've figured out how to create the bone and even create the constraint, but don't know how to parent the focus object (the empty) to the bone's tail.
I've read the older SO question on this, but that code doesn't work anymore since it's 2.7-based.
Here's my code so far:
def link_object(object):
view_layer = bpy.context.view_layer
view_layer.active_layer_collection.collection.objects.link(object)
armature = bpy.data.armatures.new('Armature')
armature_object = bpy.data.objects.new('Armature', armature)
link_object(armature_object)
# Make it active
bpy.context.view_layer.objects.active = armature_object
# Enter edit mode
bpy.ops.object.mode_set(mode='EDIT', toggle=False)
# Add a bone
bone = armature_object.data.edit_bones.new('focusBone')
bone.head=(0,0,0)
bone.tail=(0,0,1)
# ...
#Exit armature editing; this allows bones to be used in Pose/Object modes
bpy.ops.object.mode_set(mode='OBJECT', toggle=False)
# Create constraint: bone looks at camera
constraint = bpy.context.object.pose.bones['focusBone'].constraints.new('DAMPED_TRACK')
camera=bpy.data.objects['Camera']
constraint.target=camera
# Create the empty to serve as a focus target
focus_obj = bpy.data.objects.new('focusObj', None)
focus_obj.location=(0,0,1)
link_object(focus_obj)
# QUESTION: how to parent the focus_obj to the tail of the bone?