I am new to python and need to select the tail of a bone in edit mode with python. I was used this script but it doesn’t select the tail of a bone:


So i need help to select the tail of a bone in edit mode with python code.

Any helps are very very welcome.


I'm not sure why this is, but selecting stuff in edit mode only works using bpy.ops.select_all() or execute the code in object mode and the switch back to edit mode. where ob is my armature object:
ob.data.bones['Bone'].select_tail = True
works if you're in object mode and then press tab in the viewport.

import bpy
arm = bpy.data.armatures['Armature']
bpy.ops.object.mode_set(mode='OBJECT') # .select only has an effect in object mode (don't ask me why)
for bone in arm.bones: # deselect the other bones
    bone.select = False
    bone.select_tail = False
    bone.select_head = False

arm.bones['Bone'].select_tail = True
bpy.ops.object.mode_set(mode='EDIT') # go back to Edit Mode, to see the results
| improve this answer | |
  • $\begingroup$ your script works one time perfectly and doesn't work again. I get eror Traceback (most recent call last): File "<blender_console>", line 1, in <module> NameError: name 'ob' is not defined This is your script i have used ob.data.bones['Bone'].select_tail = True any helps ? $\endgroup$ – Kask909 Apr 2 at 17:33
  • $\begingroup$ Nobody to help ? $\endgroup$ – Kask909 Apr 3 at 23:14
  • $\begingroup$ Sorry, I should have clarified. ob is your armature object. Use your code in object mode, then switch to edit. $\endgroup$ – Frederik Steinmetz Apr 5 at 14:54
  • $\begingroup$ @ Frederik Steinmetz can I have the full code iam new to python $\endgroup$ – Kask909 Apr 6 at 20:29
  • $\begingroup$ I did so, couldn't do it before today, bc. I was not in front of a computer. $\endgroup$ – Frederik Steinmetz Apr 7 at 9:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.