selecting bones in armature's edit mode

I was writing an auto tasking script to create a Deform armature from a rig

I had an issue that i couldn’t find a proper way to select bones in edit mode
the only ways to do it was either to use the “select pattern” ops
bpy.ops.object.select_pattern(pattern =
or to select it in pose mode and then to switch to edit mode.
couldn’t find also anything in the documentation except for the old API.

any ideas?

I was also wondering if there ways to remove objects or bones with the standard python functions for lists like list.pop() or .remove() or can i do it only with blender’s operators?

You need to be in editmode, then set the edit_bones’ select properties,

e.g.[0].select = True
.select_head = True
.select_tail = True

Bones can be removed like

looks like you don’t see the change until you click in the viewport however…

Objects like, but only if there are no users left ( is a user). So it might be better to use bpy.ops.object.delete()


cool, thanks. it was a bit confusing between bones, edit_bones and different accesses to each one.
i was wondering if normally it would be better to use the functions in blender API rather then the blender ops?

Definitely yes:

Hey bro how can we determine the list index in the example above…