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 = bpy.data.objects["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 “bpy.context.object.data.bones.active.show_wire = 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 bpy.object.data.bones, 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.
i
mport bpy
bone_object = bpy.data.objects["gzmo_custom"]
for pbone in bpy.context.selected_pose_bones:
pbone.custom_shape = bone_object
# maybe not the most elegant, but should work fine
pbone.id_data.data.bones[pbone.name].show_wire = True