Hey All. I created a class of the type, “bpy.types.Operator”, with an “execute()” function, to create a custom object. As everyone knows, “execute()” runs in a continuous loop, responding to user input, until the operator shuts down (like, when another object is created, or the user toggles to “edit mode”.
Here is my question. Is there a way to add code, that will be run only once, as the operator shuts down? As an example, in my case, the bpy operator creates a custom object from two bezier curves (one for the path, and the other for the bevel). Once the user is done (creates another object, moves to edit mode, etc) I want the operator to convert the path to a mesh, and delete the bevel object.
As a bonus question: Is there a way to add a “Done” button to an operator?
No one has an answer to this? I have been searching for info, and the closest thing that I have found, is this use of the “Invoke” function, from the Blender/Python API:
def execute(self, context):
# rather then printing, use the report function,
# this way the message appears in the header,
self.report({'INFO'}, "Mouse coords are %d %d" % (self.x, self.y))
return {'FINISHED'}
def invoke(self, context, event):
self.x = event.mouse_x
self.y = event.mouse_y
return self.execute(context)
The Invoke function runs once, and returns a pointer to the Execute function. Can something similar be done, in the opposite order?—the Execute function, when done, returns a pointer to a custom function, which executes once, and returns “finished”. Clear as mud? Or, am I asking the impossible?