Post #5648: I investigated this, and it doesn’t seem to be a PME issue. Even without PME, ex
📋 Metadata
- Author: Pluglug
- Date: 2025-11-07 19:05:19
- Type:
answer - Quality Score: 9/10
- Reply to: post_05647
- Replies (2): post_05649, post_05650
🏷️ Tags
macro scripting advanced solved
⚙️ Related PME Features
- Macro Editor
- Python Scripting
💬 Content
I investigated this, and it doesn’t seem to be a PME issue. Even without PME, executing the same content as an operator reproduced the same phenomenon. The problem appears to be in the undo stack, and I can’t say for certain without investigating Blender’s internal implementation.
Here’s what I observed:
- Some operators cannot be controlled even when explicitly using ‘EXEC_DEFAULT’ with undo disabled (such as paint.mask_flood_fill)
- The stack shown in Edit > Undo History doesn’t match the history internally stacked during sculpt mode, causing unintended undos
- The most reliable method is to push undo at each step
I made a video explaining the problem that occurs with simple operator stacks, and how using Undo Push at each step prevents unintended undos:
If you want to completely overcome this, you’ll need to write scripts using Bmesh etc. instead of relying on Blender’s operators.
Here’s what you can try to make it work reasonably well in PME:
bpy.ops.paint.visibility_invert("EXEC_DEFAULT")
bpy.ops.ed.undo_push(message="visibility_invert")
- Execute each operator with Exec
- Use bpy.ops.ed.undo_push() as needed
- The button call might not work because you’re using open_menu(). Try calling it from the Menu tab instead.
❤️ 2 likes
image1082×280 35.3 KB