I would like to amend functionality of an existing operator with a condition check and then "proceed" with the original operator (if condition check allows it).
It is essentially what is done in answer to this question, however I would like to avoid writing the operator's code from scratch (as that answer does in main() ).

I know I can write a new operator and call the original from there but I don't want to add another operator, I want to replace (override) the original one.

So, is there a way to get to the "base" operator's methods from the override operator?

(In that example I managed to get the "OK?" prompt by adding invoke() and calling context.window_manager.popup_menu(). So that sort of solves my initial need, however, some operators are too complex to be rewritten from scratch and the need for calling the "base" operator still stands.)

  • $\begingroup$ Writing new operators code from scratch looks like it would work, then call the proceed to another operator in execute. Why don't you want to write a new operator from scratch? Can you do a OOP way and inherit the class from the parent (the operator you want to modify) and then modify/ register your child class from that ? $\endgroup$ – 4nof Jun 25 '20 at 0:16
  • $\begingroup$ Well, as I wrote in the question 4 years ago, some operators are too complex to be rewritten from scratch. Besides it has been so many projects ago that I honestly do not remember the details any more. Thanks for the down-wote, @4nof. $\endgroup$ – spacer Jun 25 '20 at 9:18
  • $\begingroup$ What's "the override operator" if you "don't want to add another operator"? Can you provide a "too complex operator to be rewritten from scratch"? Why can't you add your condition check inside the operator's execute or invoke if you "want to replace (override) the original one"? $\endgroup$ – unwave Oct 16 '20 at 19:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.