1

I'm not sure what's the right word, but I would like to manipulate the camera you see from with python BPY.

I know there are 2 cameras on startup. One camera you render from, and another camera you use to navigate around with in the scene. How do you change parameters such as position on the navigation camera?

quellenform
  • 35,177
  • 10
  • 50
  • 133
nammerkage
  • 153
  • 1
  • 2
  • 14
  • 2
  • 1
    Well not exactly, feel free to ignore. But you'll find the parameters in https://docs.blender.org/api/current/bpy.types.RegionView3D.html I explain pretty thoroughly the workflow to find how to tweak things in the linked answer. You will need to understand a bit of transform matrices though, it's not as easy as cam.position = x, y, z – Gorgious Feb 19 '23 at 19:55
  • 1
    https://blender.stackexchange.com/questions/284222/get-view-and-perspective-matrices-of-the-current-3d-viewport-not-camera and https://stackoverflow.com/a/19532463/7092409 – Gorgious Feb 19 '23 at 20:02

1 Answers1

1

I don't think Blender treats the perspective or any other view like an actual camera, unlike Maya.

You can set your current scene's camera to your current view using ⎈ Ctrl⎇ Alt0 or using the python command bpy.ops.view3d.camera_to_view(), though it requires to be run from the context of the 3D Viewport so it will look more like this:

import bpy

areas3d = [area for area in bpy.context.window.screen.areas if area.type == 'VIEW_3D'] bpy.ops.view3d.camera_to_view({'area':areas3d[0]})

More about it: scripting - Align active camera to view using python - Blender Stack Exchange

L0Lock
  • 15,965
  • 1
  • 20
  • 44