I try to remove parenting on all bones of an armature and it does not work
bpy.ops.object.mode_set(mode='POSE')
for poseBone in context.object.pose.bones:
bone = armature.data.bones[poseBone.name]
bpy.context.object.data.bones.active = bone
bpy.ops.object.parent_clear(type="CLEAR_KEEP_TRANSFORM")
bpy.ops.object.mode_set(mode='EDIT')
for editableBone in context.editable_bones:
armature.data.edit_bones.active = editableBone
bpy.ops.armature.parent_clear(type='CLEAR')
Ok ! To be honest I didn’t take the time to try the solution I provided.
I you find something that works for you in the end it’s great !
But I’m pretty sure it’s possible to remove the parenting without using bpy.ops.
As a rule of thumb, if you can do something without using bpy.ops it’s always better.
If you have time to experiment, you may try this :
bpy.ops.object.mode_set(mode='EDIT')
for bone in context.editable_bones:
bone.parent = None
All that said, if your solution using bpy.ops is working then it’s ok to keep it !