I'm writing an operator for which it is crucial that every time it gets called all the properties are set to their default values.

The ops.object.delete has 1 param. use_global. It is always false, no matter what the user put in last time it got called. I would like to replicate exactly that.

(For example: I want to modify delta scale. The default val for my_factor is 1, so nothing happens until the user alters that number. If the user calls the operator again, it will have stored whatever number the user has used last, however I want it to always start with 1.)

Add 'SKIP_SAVE' to the blender property option set.

When defining properties for the operator, any with 'SKIP_SAVE' in their property definition options set, will (like the name suggests) not be saved, and revert to their default value the next time the operator is invoked.

    scale_factor = bpy.props.FloatProperty(name="Scale Factor",
default=1,
options={'SKIP_SAVE'})

• Also a nice approach, also in my case simpler. Thank you. – Frederik Steinmetz Nov 10 '17 at 20:42

Add an invoke method to your operator and reset your property.

import bpy

class SimpleOperator(bpy.types.Operator):
"""Tooltip"""
bl_idname = "object.simple_operator"
bl_label = "Simple Object Operator"
bl_options = {'REGISTER', 'UNDO'}

d_loc = bpy.props.FloatProperty(name="Delta Location", default=1)

@classmethod
def poll(cls, context):
return context.active_object is not None

def execute(self, context):
delta_vector = (self.d_loc, self.d_loc, self.d_loc)
context.active_object.delta_location = delta_vector
return {'FINISHED'}

def invoke(self, context, event):
self.d_loc = 1.0
return self.execute(context)

def register():
bpy.utils.register_class(SimpleOperator)

def unregister():
bpy.utils.unregister_class(SimpleOperator)

if __name__ == "__main__":
register()

bpy.ops.object.simple_operator() # test call


Example based on Python > Templates > Operator Simple.

• Thank you very much, works like a charm. Just to be clear invoke() is what happens the 1. time you execute the operator and execute is what happens everytime you change a value? – Frederik Steinmetz Nov 10 '17 at 9:51