Getting viewport camera position+rotation?

Is there any way to get the position and orientation of the viewport camera with the python api? I’d like to be able to create a camera (select an exising camera) and place it at the current viewport view with matching orientation (basically the opposite of selecting view->camera view). I’m not sure if the viewport camera is a physical camera per se, so I assume if it isn’t then grabbing position and rotation data would not be possible?

you can get the viewport matrix with


here is an example of what I think your trying to do

Oooh, cheers, that did the trick. :slight_smile: