syntax help for bone properties

I am having trouble with syntax and could really use some help.

I have a simple bit of code that replaces all selected bones with a custom shape. This works great. (go to pose mode, select the bones to change, and run the script) You have to set the bone_object to be the name of the custom bone you wish to use.

import bpy

bone_object =["gzmo_custom"]

for ob in bpy.context.selected_pose_bones:    
    #ob.show_wire = True
    ob.custom_shape = bone_object

Now I need to set the bone property “show_wire” to True.
In the python console, I can type “ = True” to do this, but in the script it is not as simple as adding “ob.show_wire = True”

I see the difference is that show_wire uses, while custom_shape uses bpy.object.pose.bones, but I don’t know what to do with this info.


show_wire is a property of Bone (and EditBone), not PoseBone.

bpy.context.selected_pose_bones is a list of PoseBones. You need to enable show_wire on the corresponding bone / edit bone. custom_shape however is a PoseBone property.

mport bpy

bone_object =["gzmo_custom"]

for pbone in bpy.context.selected_pose_bones:    
    pbone.custom_shape = bone_object

    # maybe not the most elegant, but should work fine[].show_wire = True

Thank you, that works!

I knew of the edit bone and pose bone differences, but I couldn’t figure out how to access the data. Adding this to my notes for next time.

There’s also some info in the docs:

Thanks for that too. That’s another bookmark for me to go through soon.