Disappearing grid and wrongly labeled "Front Orthographic" instead of "Top Orthographic" view #93779

Closed
opened 2021-12-07 00:11:53 +01:00 by Johannes Schmitz · 4 comments

System Information
Operating system: Linux Mint
Graphics card: Nvidia GTX 2060 Super

Blender Version
Broken: 2.93.5

Short description of error
When going back to the a stored previous topview Blender mistakenly shows it as "Front Orthographic" instead of "Top Orthographic". Also the grid disappears.

Exact steps for others to reproduce the error

  • Load script below, press ESC once to exit
  • Go to Layout then set "Top Orthographic" view
  • Run modal operator from script with F3: "Sideview Operator"
  • Press and hold S button to toggle sideview
  • Release S button to observe the problem
  • Press ESC to exit
import bpy

from mathutils import Euler
from math import pi


class SideviewOperator(bpy.types.Operator):
    bl_idname = "object.sideview_operator"
    bl_label = "Simple Sideview Operator"

    state = 'DISABLED'

    def __init__(self):
        print("Start")

    def __del__(self):
        print("End")

    def execute(self, context):
        return {'FINISHED'}

    def modal(self, context, event):
        # state side view for elevation adjustment
        if event.type == 'S':
            if event.value == 'PRESS':
                if self.state == 'DISABLED':
                    # Remember previous view
                    view3d = context.space_data
                    self.view_rotation_previous = view3d.region_3d.view_rotation.copy()
                    self.view_perspective_previous = view3d.region_3d.view_perspective
                    self.is_orthographic_side_view_previous = view3d.region_3d.is_orthographic_side_view
                    # Look at object from side with some rotation
                    bpy.ops.view3d.view_axis(type='LEFT', align_active=False, relative=False)
                    region_view3d = view3d.region_3d
                    region_view3d.view_rotation.rotate(Euler((0, 0, pi/4)))
                    self.state = 'SIDEVIEW'
            elif event.value == 'RELEASE':
                if self.state == 'SIDEVIEW':
                    # Restore previous view
                    view3d = context.space_data
                    view3d.region_3d.view_rotation = self.view_rotation_previous
                    view3d.region_3d.view_perspective = self.view_perspective_previous
                    view3d.region_3d.is_orthographic_side_view = self.is_orthographic_side_view_previous
                self.state = 'DISABLED'
        elif event.type in {'ESC'}:  # Cancel
            return {'CANCELLED'}

        return {'RUNNING_MODAL'}

    def invoke(self, context, event):
        self.execute(context)

        context.window_manager.modal_handler_add(self)
        return {'RUNNING_MODAL'}

# Only needed if you want to add into a dynamic menu
def menu_func(self, context):
    self.layout.operator(SideviewOperator.bl_idname, text="Sideview Operator")

# Register and add to the object menu (required to also use F3 search "Sideview Operator" for quick access)
bpy.utils.register_class(SideviewOperator)
bpy.types.VIEW3D_MT_object.append(menu_func)

# test call
bpy.ops.object.sideview_operator('INVOKE_DEFAULT')
**System Information** Operating system: Linux Mint Graphics card: Nvidia GTX 2060 Super **Blender Version** Broken: 2.93.5 **Short description of error** When going back to the a stored previous topview Blender mistakenly shows it as "Front Orthographic" instead of "Top Orthographic". Also the grid disappears. **Exact steps for others to reproduce the error** - Load script below, press ESC once to exit - Go to Layout then set "Top Orthographic" view - Run modal operator from script with F3: "Sideview Operator" - Press and hold S button to toggle sideview - Release S button to observe the problem - Press ESC to exit ``` import bpy from mathutils import Euler from math import pi class SideviewOperator(bpy.types.Operator): bl_idname = "object.sideview_operator" bl_label = "Simple Sideview Operator" state = 'DISABLED' def __init__(self): print("Start") def __del__(self): print("End") def execute(self, context): return {'FINISHED'} def modal(self, context, event): # state side view for elevation adjustment if event.type == 'S': if event.value == 'PRESS': if self.state == 'DISABLED': # Remember previous view view3d = context.space_data self.view_rotation_previous = view3d.region_3d.view_rotation.copy() self.view_perspective_previous = view3d.region_3d.view_perspective self.is_orthographic_side_view_previous = view3d.region_3d.is_orthographic_side_view # Look at object from side with some rotation bpy.ops.view3d.view_axis(type='LEFT', align_active=False, relative=False) region_view3d = view3d.region_3d region_view3d.view_rotation.rotate(Euler((0, 0, pi/4))) self.state = 'SIDEVIEW' elif event.value == 'RELEASE': if self.state == 'SIDEVIEW': # Restore previous view view3d = context.space_data view3d.region_3d.view_rotation = self.view_rotation_previous view3d.region_3d.view_perspective = self.view_perspective_previous view3d.region_3d.is_orthographic_side_view = self.is_orthographic_side_view_previous self.state = 'DISABLED' elif event.type in {'ESC'}: # Cancel return {'CANCELLED'} return {'RUNNING_MODAL'} def invoke(self, context, event): self.execute(context) context.window_manager.modal_handler_add(self) return {'RUNNING_MODAL'} # Only needed if you want to add into a dynamic menu def menu_func(self, context): self.layout.operator(SideviewOperator.bl_idname, text="Sideview Operator") # Register and add to the object menu (required to also use F3 search "Sideview Operator" for quick access) bpy.utils.register_class(SideviewOperator) bpy.types.VIEW3D_MT_object.append(menu_func) # test call bpy.ops.object.sideview_operator('INVOKE_DEFAULT') ```

Added subscriber: @johschmitz

Added subscriber: @johschmitz

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

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

This issue was referenced by 3ecc03c3d6

This issue was referenced by 3ecc03c3d6b7baeee900a7ffd97fc0c2701adbc5

Changed status from 'Confirmed' to: 'Resolved'

Changed status from 'Confirmed' to: 'Resolved'
Campbell Barton self-assigned this 2022-05-19 06:32:43 +02: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#93779
No description provided.