Python scripts calling bpy.ops.paint.image_paint operates undo steps for "individual calls" rather than "all calls" during modal operation #54496

Open
opened 2018-04-02 20:03:14 +02:00 by Rob Hughes · 7 comments

System Information
5820K and GTX970
Windows 10

Blender Version
Latest daily build (but same problem in earlier ones too)

Short description of error
I have a modal operator which uses image_paint function.
After using it, if I do an undo, I would expect all paint operations during modal operation to be undone.
However every call to image_paint adds another item to the undo list which means I have to undo through every mouse move.
If I have moved the mouse more than (max undo items) then I can't get back to the position before I started the operator at all (making the undo pointless)

This doesn't seem to be the consistent with other modal operator. For example, in the docs https://docs.blender.org/api/blender_python_api_current/bpy.types.Operator.html the modal excecution example (with the addition of UNDO added to bl_options) moves a cube. Many changes can be made to the position of the cube during the modal operation. However one undo (correctly in my option) puts the cube back in the original place before the operator is run.

I did try using UNDO_GROUPED in my bl_options as well as UNDO - neither worked.

If I am doing something wrong or stupid in my code - sorry!

Exact steps for others to reproduce the error
Load the attached scene.
Press Run Script
Hover over cube.
Right click
Press space
Type in Simple Paint Operator to activate operator
Press mouse button to stop the operator
Try Undoing - it undo things one mouse move at a time

modal_paint.blend1

**System Information** 5820K and GTX970 Windows 10 **Blender Version** Latest daily build (but same problem in earlier ones too) **Short description of error** I have a modal operator which uses image_paint function. After using it, if I do an undo, I would expect all paint operations during modal operation to be undone. However every call to image_paint adds another item to the undo list which means I have to undo through every mouse move. If I have moved the mouse more than (max undo items) then I can't get back to the position before I started the operator at all (making the undo pointless) This doesn't seem to be the consistent with other modal operator. For example, in the docs [https://docs.blender.org/api/blender_python_api_current/bpy.types.Operator.html ](URL) the modal excecution example (with the addition of UNDO added to bl_options) moves a cube. Many changes can be made to the position of the cube during the modal operation. However one undo (correctly in my option) puts the cube back in the original place before the operator is run. I did try using UNDO_GROUPED in my bl_options as well as UNDO - neither worked. If I am doing something wrong or stupid in my code - sorry! **Exact steps for others to reproduce the error** Load the attached scene. Press Run Script Hover over cube. Right click Press space Type in Simple Paint Operator <return> to activate operator Press mouse button to stop the operator Try Undoing - it undo things one mouse move at a time [modal_paint.blend1](https://archive.blender.org/developer/F2576956/modal_paint.blend1)
Author

Added subscriber: @RevDr

Added subscriber: @RevDr
Rob Hughes changed title from Undo with bpy.ops.paint.image_paint operates for individual calls rather than all calls to Undo with bpy.ops.paint.image_paint operates for "individual calls" rather than "all calls" during modal operation 2018-04-02 20:03:55 +02:00
Campbell Barton was assigned by Aaron Carlisle 2018-04-03 20:54:33 +02:00
Campbell Barton changed title from Undo with bpy.ops.paint.image_paint operates for "individual calls" rather than "all calls" during modal operation to Python scripts calling bpy.ops.paint.image_paint operates undo steps for "individual calls" rather than "all calls" during modal operation 2019-01-31 06:55:06 +01:00

Added subscriber: @ZedDB

Added subscriber: @ZedDB

I can reproduce this on 2.8 too.

I can reproduce this on 2.8 too.
Campbell Barton was unassigned by Dalai Felinto 2019-12-23 16:36:17 +01:00

Added subscriber: @ideasman42

Added subscriber: @ideasman42

Added subscriber: @dr.sybren

Added subscriber: @dr.sybren

Latest daily build (but same problem in earlier ones too)

Please always report an exact version number.

I can't reproduce this as-is, when trying to paint Blender tells me "Missing Textures, detected!".

@ideasman42 Can you tell whether this is a bug or a known limitation? It looks like the latter to me.

> Latest daily build (but same problem in earlier ones too) Please always report an exact version number. I can't reproduce this as-is, when trying to paint Blender tells me "Missing Textures, detected!". @ideasman42 Can you tell whether this is a bug or a known limitation? It looks like the latter to me.
Author

Hi,
That scene was originally made for 2.79 which causes the "missing textures, detected" error on latest version.

I have updated the scene to work on today's build :
2.83Alpha - Data 2020-02-04 11:40 Hash cd0a028624
and can confirm the issue still exists.

Updated scene file is attached.modal_paint_2.blend

Given it is no longer 2.79, the process to cause problem is now....

Load the attached scene.
Press Run Script
Hover over cube.
Press F3
Type in Simple Modal Operator to activate operator
Move mouse around to paint on cube
Press mouse button to stop the operator
Try Undoing - it undo things one mouse move at a time

Hi, That scene was originally made for 2.79 which causes the "missing textures, detected" error on latest version. I have updated the scene to work on today's build : 2.83Alpha - Data 2020-02-04 11:40 Hash cd0a02862404 and can confirm the issue still exists. Updated scene file is attached.[modal_paint_2.blend](https://archive.blender.org/developer/F8320747/modal_paint_2.blend) Given it is no longer 2.79, the process to cause problem is now.... Load the attached scene. Press Run Script Hover over cube. Press F3 Type in Simple Modal Operator <return> to activate operator Move mouse around to paint on cube Press mouse button to stop the operator Try Undoing - it undo things one mouse move at a time
Philipp Oeser removed the
Interest
Python API
label 2023-02-10 09:04:47 +01:00
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
4 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#54496
No description provided.