1
$\begingroup$

I've been stuck for a few hours on this problem and I can't seem to find any solution.

problem :(

I want to select those two bones(abs bone is named "Bone.005" and leg bone is named "Bone") in Scripting mode,but when I do it with RMB + SHIFT RMB to select those two with the mouse I can't get any code line.

If someone can help me out,I would really appreciate !

$\endgroup$
1
  • $\begingroup$ Answer provided, I hope it helps. Don't forget to accept it if it solved your problem. $\endgroup$
    – Tak
    Commented Mar 9, 2017 at 11:30

1 Answer 1

4
$\begingroup$

This is a script which selects Bone and Bone.005 from Armature.003

import bpy

arm = bpy.data.objects['Armature.003']
bpy.ops.object.mode_set(mode='EDIT')
bpy.ops.armature.select_all(action='DESELECT')

bones_to_select = ['Bone','Bone.005']
for bone in arm.data.edit_bones:
    if bone.name in bones_to_select:
        bone.select = True
$\endgroup$
3
  • $\begingroup$ Do you have a way to select the whole bone ( i mean its head and tail included ) ? Because the script just selects the body of the bone. $\endgroup$
    – holl0w
    Commented Mar 9, 2017 at 23:05
  • 1
    $\begingroup$ @holl0w the script selects the whole bone including its head and tail, there is nothing called body of bone. So run the script then hit G to grab them and you will find the whole bones moving. $\endgroup$
    – Tak
    Commented Mar 9, 2017 at 23:20
  • $\begingroup$ use this in you need context: bpy.context.object.data.edit_bones['pelvis'].select = True $\endgroup$
    – aftamat4ik
    Commented Jul 17, 2022 at 6:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .