I have an operator that I need to hand over arguments. I know that one possibility is to add attributes to the scene and use this but in draw
-methods of operators I can modify the arguments passed to the operator directly. So I thought I should be able to do this from the console.
So far I have this operator (as an example):
from bpy.types import Operator
from bpy.props import StringProperty
class ExampleOP(Operator):
bl_idname = "object.test"
bl_label = "Is just an example"
bl_options = {'REGISTER'}
foo = StringProperty()
result = StringProperty()
def invoke(self, context, event):
return context.window_manager.invoke_props_dialog(self)
def draw(self, context):
layout = self.layout
col = layout.column()
col.prop_search(self, 'result', context.object.data, 'uv_textures', text="UV Layer")
def execute(self, context):
print(foo)
return {'FINISHED'}
What I want to do is bpy.ops.object.test('INVOKE_DEFAULT', foo="something").
EDIT: It seems to me that the answer only works for *Property()-objects not any object. This gives me a
TpyeError: Convering py args to operator properties: keyword "ev" unrecognized
Note: Please do not post any answers telling me off, to do this in another way. NO, this is exactly what I need, I cannot handle the "print-statement" outwards of the operator and yes, and foo may not always be a StringProperty.