I'm trying to duplicate some bones but for some reason it's not working at all, there's no error on runtime, it simply won't duplicate the selected bones. Do you have any idea why it's happening?
import bpy
def create_tgt():
armature = bpy.data.objects['Armature'] # Use your armature name
bones = armature.data.edit_bones[:] # This'll give us a list with all bones
if not bpy.context.mode == 'EDIT_ARMATURE':
bpy.ops.armature.select_all(action='DESELECT')
armature.select = True
bpy.ops.object.mode_set(mode='EDIT')
for bone in bones: # Let's loop through them all
if 'DEF-' in bone.name:
bone.select = True
bpy.ops.armature.duplicate()
create_tgt()
After running this script, no bones are selected and no bones are duplicated.