1
$\begingroup$

I am trying to select a bone and make it active in 2.80, so I can run an operation on it (connect it to its parent), the bone gets selected, but does not get active, as shown in the picture, when active, the name of the bone appears in the interface, anyone has an idea what might be the problem here?

enter image description here

Here is the code I use…

bone.select = True;
bone.select_head = True;
bone.select_tail = True;
bpy.ops.armature.parent_set(type=‘CONNECTED’)

Thanks in advance Gilles

$\endgroup$
0
$\begingroup$

API properties.

Set the active bone with arm.edit_bones.active = bone. However propose there is no need to use the parenting operator, can rather set the properties, parent, use_connect

Python console code with armature arm in edit mode.

>>> arm
bpy.data.armatures['Armature']

>>> bone = arm.edit_bones["Bone"]
>>> bone2 = arm.edit_bones["Bone.001"]
>>> # active edit bone
>>> C.active_bone.name
'Bone.001'
# set active edit bone
>>> arm.edit_bones.active = bone
>>> C.active_bone.name
'Bone'
>>> bone2.parent = bone
>>> bone2.parent.name
'Bone'
# check if connected.. nope
>>> bone2.use_connect
False
# connect
>>> # connect the bone
>>> bone2.use_connect = True
>>> 
$\endgroup$
  • $\begingroup$ I tried arm.edit_bones.active = bone before, but not in the right context, now it works, looking at the other code as we speak ! Thanks a bunch for the reply, I really appreciate it ! $\endgroup$ – Gilles Feb 24 '19 at 14:48

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.