For my activities it would be very convenient to invoke operators specifying, as parameter, a function that has to be called back by the operator itself.
There exist a PointerProperty, but after a test I realised that it is not fulfilling my needs.
Is there any way to simulate this behaviour?
Any plan to add a FunctionProperty, or InstanceProperty, to the Blender code base?
Any theoretical limitations?
specifying, as parameter, a function that has to be called back
If you limit the number of possible functions that can be called back you could construct a simple way to call a function upon operator termination.
def iAmAnOperator(passedExitType):
# Do work.
if passedExitType == 0:
# Activate calback to this function.
myFuncType0 ()
if passedExitType == 1:
# Activate calback to this function.
myFuncType1 ()
Not really elegant or fancy but if you just need to get the job done to support a few call backs it might work.
Thanks for the suggestion CoDEmanX.
Of course this solution would work only with global level-functions.
I would prefer to directly pass the function symbol, instead on relying on strings, but you proposal might match my need. I’ll try it soon.
Why I need it?
Because I coded a pretty huge and complex modal operator.
Now I want to freeze its code and yet keep it general purpose.
So, according to the specific needs, at the moment of invocation I want to specify some extra code to be executed and the end of the modal() execution.
Is it understandable?
The operator system doesn’t support functions as arguments, as well as any other python objects. Only bpy.props are supported. See here for the reason: