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"
@classmethod
def poll(self,context):
if(bpy.context.active_object.type == 'ARMATURE'):
return(True)
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():
bpy.utils.register_class(dwarfButtons)
def unregister():
bpy.utils.unregister_class(dwarfButtons)
if __name__=="__main__":
register()
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.