I’m trying to create a button in the Tools Tab to call my own code.
This is what I came up with so far researching.
import bpy
from bpy.types import Panel, Operator
class LegsOperator(Operator):
bl_idname = "legs_operator"
bl_label = "LegsOP"
def execute(self, context)
bpy.context.object.pose.bones["LeftArm"].rotation_quaternion[1] = 5
return {'FINISHED'}
class BodypartPosesPanel(Panel):
bl_space_type = 'VIEW_3D'
bl_region_type = 'TOOLS'
bl_label = "Legs"
bl_context = "posemode"
bl_category = "Bodypart Poses"
def draw(self, context):
layout = self.layout
obj = context.object
row = layout.row()
row.operator("legs_operator",text="click here")
def register():
bpy.utils.register_class(BodypartPosesPanel)
bpy.utils.register_class(LegsOperator)
def unregister():
bpy.utils.unregister_class(LegsOperator)
bpy.utils.unregister_class(BodypartPosesPanel)
if __name__ == "__main__":
register()
print("my stuff loaded")
My it fails when I execute the script, I got error at:
def execute(self, context)
can somebody give me some direction?
thank you very much for the time