toolsettings.use_snap registers an undo when used in conjunction with bpy.ops.transform.translate #79295

Closed
opened 2020-07-26 20:10:08 +02:00 by Ethan Simon · 13 comments

System Information
Operating system: Windows-10-10.0.18362-SP0 64 Bits
Graphics card: GeForce GTX 1080/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 451.77

Blender Version
Broken: version: 2.83.0, branch: master, commit date: 2020-06-03 14:38, hash: 211b6c29f7
Worked: (newest version of Blender that worked as expected)

Short description of error
OK so I have been trying to crack the code for a while now but I think I figured out the error with my code and it may be an error with the API. I have made a modal operator that allows the user to manually change where the origin is placed, with similar functionality to Mayas pivot editing system. The issue lies with using the use_snap option in toolsettings. It does not seem to register undo states properly in conjunction with a translate bpy.ops. Regardless of the context it always seems to register use_snap as true when you go back into the translate undo state, turning it back on.

My theory is the use_snap option is linked to the translate modal when both are used in conjunction and treats it as one, turning it back on when you redo into the translate state. The ideal scenario is the translate modal be separated from toolsettings.use_snap and saves the undo state properly like every other setting changed (if it needed to be mentioned this is the ONLY toolsetting that reacts this way, and conveniently the only option related to the translate modal).

Here is the pastebin for my code. I ripped it from my scripts so I tried to make it work on its own but if it doesn't it shouldn't be difficult to get it working: https://pastebin.com/d5e0Yzhy

Exact steps for others to reproduce the error
To reproduce the issue using the operator within the paste bin, if you use it on a mesh, undo and then redo back into the operators undo state everything will work as intended except for snapping which turns back on. The intended result is for the snapping to be how it was post-use of the operator. This issue happens if you undo into ANY undo state in which you used the operator, not just if you undo and redo.

Here is a gif to show the issue, after running the operation I simply undo and redo... and there is the issue: https://imgur.com/a/K6kVSE2

I don't have a solution for this problem, so if you somehow do and would be willing to share I would greatly appreciate it.

**System Information** Operating system: Windows-10-10.0.18362-SP0 64 Bits Graphics card: GeForce GTX 1080/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 451.77 **Blender Version** Broken: version: 2.83.0, branch: master, commit date: 2020-06-03 14:38, hash: `211b6c29f7` Worked: (newest version of Blender that worked as expected) **Short description of error** OK so I have been trying to crack the code for a while now but I think I figured out the error with my code and it may be an error with the API. I have made a modal operator that allows the user to manually change where the origin is placed, with similar functionality to Mayas pivot editing system. The issue lies with using the use_snap option in toolsettings. It does not seem to register undo states properly in conjunction with a translate bpy.ops. Regardless of the context it always seems to register use_snap as true when you go back into the translate undo state, turning it back on. My theory is the use_snap option is linked to the translate modal when both are used in conjunction and treats it as one, turning it back on when you redo into the translate state. The ideal scenario is the translate modal be separated from toolsettings.use_snap and saves the undo state properly like every other setting changed (if it needed to be mentioned this is the ONLY toolsetting that reacts this way, and conveniently the only option related to the translate modal). Here is the pastebin for my code. I ripped it from my scripts so I tried to make it work on its own but if it doesn't it shouldn't be difficult to get it working: https://pastebin.com/d5e0Yzhy **Exact steps for others to reproduce the error** To reproduce the issue using the operator within the paste bin, if you use it on a mesh, undo and then redo back into the operators undo state everything will work as intended except for snapping which turns back on. The intended result is for the snapping to be how it was post-use of the operator. This issue happens if you undo into ANY undo state in which you used the operator, not just if you undo and redo. Here is a gif to show the issue, after running the operation I simply undo and redo... and there is the issue: https://imgur.com/a/K6kVSE2 I don't have a solution for this problem, so if you somehow do and would be willing to share I would greatly appreciate it.
Author

Added subscriber: @razed

Added subscriber: @razed
Ethan Simon changed title from Python API issue - Activating on snapping registers an undo regardless of context to toolsettings.use_snap registers an undo regardless of context 2020-07-26 20:14:07 +02:00
Author

Maybe this code is automatically getting optimized since toolsettings.use_snap is inherently the same as the snap option in the translate modal? I have never looked at the source code before and cannot write in C++, but I am going to see if I can crack it open and find what I am looking for. If I don't get a response in a few days I will try to simplify the operator to better get to the root of the issue.

Maybe this code is automatically getting optimized since toolsettings.use_snap is inherently the same as the snap option in the translate modal? I have never looked at the source code before and cannot write in C++, but I am going to see if I can crack it open and find what I am looking for. If I don't get a response in a few days I will try to simplify the operator to better get to the root of the issue.
Ethan Simon changed title from toolsettings.use_snap registers an undo regardless of context to toolsettings.use_snap registers an undo when used in conjunction with bpy.ops.transform.translate 2020-07-27 16:08:52 +02:00

Added subscriber: @mano-wii

Added subscriber: @mano-wii

Changed status from 'Needs Triage' to: 'Needs User Info'

Changed status from 'Needs Triage' to: 'Needs User Info'

Thanks for the report. Unfortunately the scenario described is too time consuming for us to track down, we require the bug reporter to narrow down the problem.
Also, this bug tracker does not provide support for unofficial addons/scripts.
If you are sure that the problem is with blender, please simplify the script to just a few lines.


I have made a modal operator that allows the user to manually change where the origin is placed,

I don't know what the intention is, but this feature already exists in blender:
https://docs.blender.org/manual/en/dev/scene_layout/object/editing/transform/control/options.html#bpy-types-toolsettings-use-transform-data-origin

Thanks for the report. Unfortunately the scenario described is too time consuming for us to track down, we require the bug reporter to narrow down the problem. Also, this bug tracker does not provide support for unofficial addons/scripts. If you are sure that the problem is with blender, please simplify the script to just a few lines. ---- > I have made a modal operator that allows the user to manually change where the origin is placed, I don't know what the intention is, but this feature already exists in blender: https://docs.blender.org/manual/en/dev/scene_layout/object/editing/transform/control/options.html#bpy-types-toolsettings-use-transform-data-origin
Author

Thanks for the response Germano, this issue is not directly related to my own personal scripts, it could happen in any script utilizing enabling snapping automatically.

https://pastebin.com/d5e0Yzhy here is a simplified version of the operator which is completely commented to better explain what is going on. I also included an example where it works as intended to kind of drive the point home.

So for the intention. This specific tool merges the use of affect only origins (or an alternate method using empties since versions older than 2.82 don't support the feature) to allow the user to one click translate the origin wherever they please.

Thanks for the response Germano, this issue is not directly related to my own personal scripts, it could happen in any script utilizing enabling snapping automatically. https://pastebin.com/d5e0Yzhy here is a simplified version of the operator which is completely commented to better explain what is going on. I also included an example where it works as intended to kind of drive the point home. So for the intention. This specific tool merges the use of affect only origins (or an alternate method using empties since versions older than 2.82 don't support the feature) to allow the user to one click translate the origin wherever they please.
Author

Changed status from 'Needs User Info' to: 'Needs Developer To Reproduce'

Changed status from 'Needs User Info' to: 'Needs Developer To Reproduce'
Author

I think this is the right thing to do? Apologies if I am misusing this.

I think this is the right thing to do? Apologies if I am misusing this.
Member

Changed status from 'Needs Developer To Reproduce' to: 'Needs Triage'

Changed status from 'Needs Developer To Reproduce' to: 'Needs Triage'

I can't reproduce the problem (has it been solved yet?)
Btw, there is a known issue with the design of undo steps that is being explained in #56163 (Improve MemFile Undo (for general use))

I can't reproduce the problem (has it been solved yet?) Btw, there is a known issue with the design of undo steps that is being explained in #56163 (Improve MemFile Undo (for general use))
Author

@mano-wii I tested on the 2.92 alpha and it seems to not be occurring any longer. I guess that means it was solved? Would be curious to know what fixed it, but otherwise seems like that covers it :)

@mano-wii I tested on the 2.92 alpha and it seems to not be occurring any longer. I guess that means it was solved? Would be curious to know what fixed it, but otherwise seems like that covers it :)

Changed status from 'Needs Triage' to: 'Resolved'

Changed status from 'Needs Triage' to: 'Resolved'
Germano Cavalcante self-assigned this 2020-11-24 14:48:51 +01:00

Good to know it was resolved :)
We could ask more developers or do git bisect to find out which commit solved the problem.
But for now I will just close as resolved.

Good to know it was resolved :) We could ask more developers or do git bisect to find out which commit solved the problem. But for now I will just close as resolved.
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
3 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#79295
No description provided.