view on selected object #37494

Closed
opened 2013-11-16 17:26:22 +01:00 by Fekete Eduard · 8 comments

System Information
Windows 7 64bit, Nvidia GTX 660 TI, Intel Core i5 3570k

Short description of error
"view selected" (bpy.ops.view3d.view_selected()) does not work if called from an update Property Method.

Exact steps for others to reproduce the error
Just run the script in my blend file. I created a UI List on the right "sidebar" in 3D-View where you can chose an Element from my listvar (Black_objnameslist).
I want the view to focus on this selected object, but it does not work, although the context is in 3D-View !

**System Information** Windows 7 64bit, Nvidia GTX 660 TI, Intel Core i5 3570k **Short description of error** "view selected" (bpy.ops.view3d.view_selected()) does not work if called from an update Property Method. **Exact steps for others to reproduce the error** Just run the script in my blend file. I created a UI List on the right "sidebar" in 3D-View where you can chose an Element from my listvar (Black_objnameslist). I want the view to focus on this selected object, but it does not work, although the context is in 3D-View !
Author

Changed status to: 'Open'

Changed status to: 'Open'
Author

Added subscriber: @EdwardBlack

Added subscriber: @EdwardBlack

Added subscriber: @brecht

Added subscriber: @brecht

There seems to be no .blend file attach?

But note that this operator needs to run in the context of the main region of the 3D view, not the sidebar. So you may need to set context to EXEC_REGION_WIN or INVOKE_REGION_WIN to make it run in the other region:
http://www.blender.org/documentation/blender_python_api_2_69_1/bpy.ops.html#execution-context

There seems to be no .blend file attach? But note that this operator needs to run in the context of the main region of the 3D view, not the sidebar. So you may need to set context to EXEC_REGION_WIN or INVOKE_REGION_WIN to make it run in the other region: http://www.blender.org/documentation/blender_python_api_2_69_1/bpy.ops.html#execution-context
Author

Hmm, let me upload it again, maybe there was an error. sorry.
{F28035}
Can you show me how to fix it pls ? Where to put EXEC_REGION_WIN or INVOKE_REGION_WIN in my code so that it works? I can't figure it out. Pls Help!

Hmm, let me upload it again, maybe there was an error. sorry. {F28035} Can you show me how to fix it pls ? Where to put EXEC_REGION_WIN or INVOKE_REGION_WIN in my code so that it works? I can't figure it out. Pls Help!

Change this:

if bpy.ops.view3d.view_selected.poll():
    bpy.ops.view3d.view_select()  

to this:

try:
    bpy.ops.view3d.view_selected('EXEC_REGION_WIN')
except:
    pass
Change this: ``` if bpy.ops.view3d.view_selected.poll(): bpy.ops.view3d.view_select() ``` to this: ``` try: bpy.ops.view3d.view_selected('EXEC_REGION_WIN') except: pass

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' to: 'Resolved'
Brecht Van Lommel self-assigned this 2013-11-16 18:21:32 +01:00
Author

Thank you so much brecht! Now it works great :) i have spent so many hours to search for the solution, and finally someone helped me :) thx thx thx!
PS: Sorry that i thought that it is a bug.

Thank you so much brecht! Now it works great :) i have spent so many hours to search for the solution, and finally someone helped me :) thx thx thx! PS: Sorry that i thought that it is a bug.
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
2 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#37494
No description provided.