Set Translation/Rotation of 3D-Viewport

Hey Blender-Artists,

i am developing an addon for my own camera-movement. Im so far, that i have a button in the 3d-view and onRightClick is recognized. My camera-movement just should work, when the user is pressing and holding right-click over that button, so it doesnt conflict with other key-combinations. For debug-reason it just shows the click-position in the draw-method of my addon.

now i want to work on the camera-movement but i have no idea how to get/set the current translation/rotation of the viewport. how is that possible?


Nobody knows? Its not possible?

Thats very important for me, because the current movement-system sucks and i have to replace it with my own, or i will use maya further.

what kind of behaviour are you looking for? describe it.

hey zeffii, we wrote already in irc. :smiley:

you sayed i should try bpy.ops.view3d.rotate() and bpy.ops.view3d.move(), but unfortunately they dont take any arguments or the documentation doesnt informate about them (

why do you need the camera-behaviour discribed?

You are trying to code some behaviour, in order for me to see if i can assist you might consider taking your time to describe what you want to achieve, what the mouse will do to what view.

i want to implement two behaviours:

  • spectating like in quake-engine-games
  • movement like in the map-editor radiant for cod2

the first one is like Shift+F (without the smoothing). so movement with WASD, up/down with E/Q and camera-control with mouse.

I think you just mess with the viewport matrix to do what you want – pretty sure it isn’t read-only anymore.

Hey Uncle Entity,

so i tried


but after the call the whole callback_add-draw-method stop drawing.

do you know how to get the matrix? i just find informations to the old api.

Hi all. I’m newbie to Blender Python API but I have some knowledge of pure Python.
I work in big studio and several people are getting more and more disappointed with our company’s software.
So I volunteered to help them to study Blender. The biggest problem is when artist work in some software several years, it’s very hard for him to master brand new program like Blender.
So, most of the setting I’ve customized the only thing I’d like to adopt is our accustomed navigation in 3D Viewport. We need possibility to navigate via WASD for camera movement and mouse for camera rotation (like in Unity or CryEngine).
After one day of investigation I adopted template that comes with Blender. I can move camera with WASD keys but I can’t make it rotate with mouse. And frankly speaking I’d like also to control camera movement speed.
Cannot attach my WIP-script :frowning:
Please If you have some free time - help us at least with advice what to do :slight_smile:

if you got translation right based on template, you should also manage to do that for rotation, just use Region3D.view_matrix, the event object of the modal method (event.mouse_x, event.mouse_y) and if needed Region.x / y / width / height and Region.view3d.region_to_area or area_to_region