bpy.ops.wm.open_mainfile command overwrite the existing file without warning #104804

Closed
opened 2023-02-16 05:02:02 +01:00 by Himanshu-Jain · 5 comments

System Information
Operating system: Windows-10-10.0.17763-SP0 64 Bits
Graphics card: SVGA3D; build: RELEASE; LLVM; VMware, Inc. 3.3 (Core Profile) Mesa 19.1.0 (git-cee1f21471)

Blender Version
Broken: version: 3.4.1, branch: blender-v3.4-release, commit date: 2022-12-19 17:00, hash: rB55485cb379f7
Worked: (newest version of Blender that worked as expected)

Short description of error
bpy.ops.wm.open_mainfile command open new file in Blender without giving warning to save the existing file in Blender.

This issue can be found in Windows machine.
In Mac machine, working as expected.

Exact steps for others to reproduce the error

import bpy
bpy.ops.wm.open_mainfile(filepath=r"file.blend", check_existing=True)
System Information Operating system: Windows-10-10.0.17763-SP0 64 Bits Graphics card: SVGA3D; build: RELEASE; LLVM; VMware, Inc. 3.3 (Core Profile) Mesa 19.1.0 (git-cee1f21471) Blender Version Broken: version: 3.4.1, branch: blender-v3.4-release, commit date: 2022-12-19 17:00, hash: rB55485cb379f7 Worked: (newest version of Blender that worked as expected) Short description of error bpy.ops.wm.open_mainfile command open new file in Blender without giving warning to save the existing file in Blender. This issue can be found in Windows machine. In Mac machine, working as expected. Exact steps for others to reproduce the error ``` import bpy bpy.ops.wm.open_mainfile(filepath=r"file.blend", check_existing=True) ```
Himanshu-Jain added the
Severity
Normal
Type
Report
Status
Needs Triage
labels 2023-02-16 05:02:03 +01:00

I see same behavior with Windows and Mac machine.

AFAIK you need to pass execution context first:

import bpy
bpy.ops.wm.open_mainfile('INVOKE_DEFAULT', filepath=r"file.blend", check_existing=True)

Are you really sure this behaves differently on Mac? can you provide details for Mac machine and Blender version used?

I see same behavior with Windows and Mac machine. AFAIK you need to pass execution context first: ``` import bpy bpy.ops.wm.open_mainfile('INVOKE_DEFAULT', filepath=r"file.blend", check_existing=True) ``` Are you really sure this behaves differently on Mac? can you provide details for Mac machine and Blender version used?
Richard Antalik added
Status
Needs Information from User
and removed
Status
Needs Triage
labels 2023-02-16 05:25:51 +01:00
Author

Thanks a lot for your reply.

Yes, it is working differently on Mac.

Blender - 3.2.2
Mac - M1 Pro

Thanks a lot for your reply. Yes, it is working differently on Mac. Blender - 3.2.2 Mac - M1 Pro
Author

Yes 'INVOKE_DEFAULT' context shows a "save file" warning, but it also opens up "Blender file view" to open a file instead of opening a file mentioned in filepath argument.

Yes 'INVOKE_DEFAULT' context shows a "save file" warning, but it also opens up "Blender file view" to open a file instead of opening a file mentioned in filepath argument.
Member

To not show the file selector, you can do the following:

import bpy
bpy.ops.wm.open_mainfile(filepath=r"file.blend", check_existing=True, display_file_selector=False)

@Himanshu-Jain : that should be sufficient, no?

To not show the file selector, you can do the following: ``` import bpy bpy.ops.wm.open_mainfile(filepath=r"file.blend", check_existing=True, display_file_selector=False) ``` @Himanshu-Jain : that should be sufficient, no?
Author

So the final working solution should be,

bpy.ops.wm.open_mainfile('INVOKE_DEFAULT', filepath=r"file.blend", display_file_selector=False)

Thanks @iss & @lichtwerk

So the final working solution should be, `bpy.ops.wm.open_mainfile('INVOKE_DEFAULT', filepath=r"file.blend", display_file_selector=False)` Thanks @iss & @lichtwerk
Blender Bot added
Status
Archived
and removed
Status
Needs Information from User
labels 2023-02-16 10:22:11 +01:00
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset System
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Code Documentation
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
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
Viewport & EEVEE
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Asset Browser Project
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
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
Module
Viewport & EEVEE
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Severity
High
Severity
Low
Severity
Normal
Severity
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
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#104804
No description provided.