I'm a total beginner at coding and I'm having some troubles with my first script.

I copied the main structure from a script that toggles layer visibility for some bones from a rigging course I did at IHMAN 3D School. Now I'm trying to tweak it to fit my needs.

Aside from a quicker access to some Armature functions via Toolshelf, I want to be able to set all the selected bones to Deform=True/False at once with a button. I marked the line I wrote to accomplish this.

The script as is now goes as follows:

 import bpy

 class dwarfButtons(bpy.types.Panel):

    bl_space_type = "VIEW_3D"
    bl_region_type = "TOOLS"
    bl_category = "Rigging"
    bl_label = "Dwarf Rig Layers"

    def poll(self,context):
        if(bpy.context.active_object.type == 'ARMATURE'):

    def draw(self,context):
        layout = self.layout
        row = layout.row()

        row.label("Edit/Display options:")
        row = layout.row()
        row.prop(context.active_object.data, "use_mirror_x", toggle=True, text="edit: x mirror")
        row = layout.row()
        row.prop(context.active_object.data, "show_names", toggle=True, text="names")
        row = layout.row()
        row.prop(context.active_object.data, "show_bone_custom_shapes", toggle=True, text="shapes")
        row = layout.row()
        row.prop(context.active_object.data, "show_axes", toggle=True, text="axe display")
        row = layout.row()
        row.prop(context.active_object, "show_x_ray", toggle=True, text="xRay")
        row = layout.row()
        row.prop(context.selected_bones, "use_deform", toggle=True, text="Deform OFF") #THIS LINE

def register():

def unregister():

if __name__=="__main__":

I don't totally know what I'm doing yet. I discovered what functions to call trough the info panel and quick searches through the Python API.

  • $\begingroup$ You have to say what exactly the problem is if you paste some code. Does the script fail or does nothing etc? $\endgroup$
    – iKlsR
    Commented Aug 24, 2014 at 18:10

2 Answers 2


In edit mode select the bones you want to change and press ShiftW (on windows) and you get "Toggle Bone Options" -popup. There you can alter the deform option for all the bones selected.

Tested with Blender 2.75

  • 1
    $\begingroup$ You can also with bones selected right-click the Deform checkbox and click Copy To Selected. That will set it for all the bones. $\endgroup$ Commented Sep 20, 2015 at 11:23

The class you have created defines a panel, which is a visual element that contains items within a box that can be collapsed. The properties you display with row.prop(context.active_object.data...) will always correspond to the one active object, that is the selected object that has lighter selection highlighting than the others.

The buttons that can appear in a panel are a way to execute an operator that performs a task. An operator can perform it's task on any available data, although it is often on all selected items (not just the active item).

To change the properties on all selected bones you want to define an operator. Using blender's text editor you can start with a template for Operator Simple and you can add a panel based class to the same script if you want to. The bl_label for the operator can be used to search for it in the space bar menu, or you can use the bl_idname to refer to it in a panel or calling it directly from python.

The example operator has bl_idname set to object.simple_operator to start with, you can place a button in a panel to use it with -


The task you describe will use data that is not always defined so you need to check the existence before trying to access them, for the operator this will best be done in it's poll method.

def poll(cls, context):
    return context.active_object is not None and context.active_object.type == 'ARMATURE'

You can then alter the function used by the example operator to turn off the deform for the bones.

def main(context):
    if context.active_object.mode == 'POSE':
        for pb in context.selected_pose_bones:
            pb.bone.use_deform = False
    elif context.active_object.mode == 'EDIT':
        for pb in context.selected_bones:
            pb.use_deform = False
  • $\begingroup$ no use_deform in 3.1 in pose mode $\endgroup$
    – Phil
    Commented Jun 1, 2022 at 20:38
  • $\begingroup$ @Phil use_deform still exists in the latest blender build. $\endgroup$
    – sambler
    Commented Jun 2, 2022 at 9:59

You must log in to answer this question.

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