0

How to make a selected bone active in POSE or EDIT mode? Thanks!

lehaab
  • 11
  • 1
  • 2
    https://blender.stackexchange.com/questions/132630/how-to-make-a-bone-active https://blender.stackexchange.com/questions/134250/set-active-bone-in-pose-mode-from-python-script – batFINGER Apr 07 '21 at 18:25

2 Answers2

0

Understood how in edit mode.

bpy.ops.object.mode_set(mode='EDIT')
arm = bpy.data.armatures['Armature']
bone = arm.edit_bones["Bone"]
arm.edit_bones.active = bone
lehaab
  • 11
  • 1
0
bpy.context.object.data.bones.active = bpy.data.objects["rig"].pose.bones["spine_fk.003"].bone

This works in Blender 2.93 LTS, and a call to bpy.context.object.data.bones.active in pose mode will confirm that the bone you named is in there.
("rig" is the name of my armature, "Spine_fk.003" was the bone I happened to be using in a script). However, it doesn't actually show the bone as being active on the screen.
If you select another bone on-screen, and then dump the code into the console, it will use whatever bone you dumped in there, but still show the other bone being active on-screen. If you select a bone onscreen AFTER you put the code in, and then check the bpy.context.object.data.bones.active, it will list the one you clicked onscreen.

I honestly don't know if that's a bug, or what... I'm extremely new to this, but it seems to directly answer this question, at least for pose mode.