0
$\begingroup$

Hello folks I'm trying to execute an operator from code (like calling bpy.ops.my_operator()) and I'd like to show its UNDO-REDO panel.

(The OT's panel is showing as expected when I execute the operator via search-bar or via button in the UI, it has the UNDO option).

I need to call my_operator from a diferent operator (explained below why*) (lets call it my_other_operator). my_other_operator has not the UNDO option, by the way.

I've tried:

bpy.ops.gpencil.my_operator()
bpy.ops.gpencil.my_operator('INVOKE_DEFAULT')
bpy.ops.gpencil.my_operator('EXEC_DEFAULT')

But none of them work, they all execute the operator but they don't show the UNDO panel anymore.

Any idea how to show the menu again?

*If someone wants to know the context, I'm using different curves and color ramps that I get from a material. I can't show them in the OT's UNDO panel, and since the UNDO deletes their changes, I've made a "Re-Execute" operator that makes a backup of the values, handles the undo, and calls the operator again (so I would like to make the panel visible again).

Thank you so much for the help

$\endgroup$

1 Answer 1

0
$\begingroup$

Yes, it's possible. To get this functionality you should add the 'UNDO' key word to your operator's 'bl_options'.


  • In the Blender's text editor there are a plenty of templates. Check out the one called "Operator Mesh Add". You can find it HERE:

undo_01


  • And there you can see an example how to implemented the UNDO :

undo_02


  • If you want to have a deeper understanding of this topic I can recommend you the Blender's official tutorial which is called "Your Own Operator -- Scripting for Artists" [=link_to_youtube=]

$\endgroup$
1
  • $\begingroup$ Thanks for the help mate. Yeah, I said in my post that I set the UNDO bl_option, but what I meant is how to make the menu appear when I call the operator from code (the menu shows as expected when I execute the operator as usual). Sorry if I didn't expres myself correctly $\endgroup$
    – Ommadawn
    Commented Feb 6 at 23:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .