Is it possible to have a class method work as same as with a function, where you can put in different parameter for one instance function? Like in my case, where I need to have 8 selection options, each with different naming conventions. This works fine with a function, but I need to execute the operation with a pie menu, so I believe an operator is the only way to go?
I was hoping to have one operator for each option, but have a different variable for each in the pie menu command?
lst = ["YO!", "WAZZAP!?", "HOW'YOU'DOIN!?"]
class Print1(bpy.types.Operator):
bl_idname = "object.print1"
bl_label = "Print 1"
def execute(self, context):
self.printz()
return{"FINISHED"}
@classmethod
def printz(cls, text=lst[0]):
print(text, "What is going on in the kitchen?")
class Print2(bpy.types.Operator):
bl_idname = "object.print2"
bl_label = "Print 2"
def execute(self, context):
Print1.printz(lst[1])
return{"FINISHED"}
In this case, I have one "master" operator that feeds others, but I think there must be a simpler way than have a copy of 7 operators in code, that do almost the same thing? Can it be done as same as with basic functions?
def printz(self): print(lst[self.index])
Pass the different index in your pie menupie.operator("object.print").index = 0
$\endgroup$