I would like my custom operator to have 2 behaviours :
- Case 1: Viewport is in perspective mode, do function 1.
- Case 2: Viewport is in orthogonal mode, do function 2.
How can I get that information with the Python API?
Blender Stack Exchange is a question and answer site for people who use Blender to create 3D graphics, animations, or games. It only takes a minute to sign up.Sign up to join this community
Yes, you can check
You can get the perspective of the current context (provided the current context is a 3D view) with
For example, running this in the text editor will print
Ortho to the terminal for each 3D view.
import bpy for area in bpy.context.screen.areas: if area.type == 'VIEW_3D': for space in area.spaces: if space.type == 'VIEW_3D': if space.region_3d.is_perspective: print("Perspective") else: print("Ortho")