5
$\begingroup$

Is there a keystroke or command to view along an axis of the current transform orientation (similar to Shift+Numpad to view along an object's axis)? Assume there aren't any objects already aligned with the transform orientation.

The best way I've found is to create a dummy object (like an empty), use "Align to Transform Orientation", and then use the old Shift+Numpad keys. It's workable, but it's kind of tedious.

$\endgroup$
  • $\begingroup$ I don't think you understand. Or maybe I don't understand. There is no object aligned with the orientation. I've just created the transform orientation (specifically in Python, although there are other ways this could be useful). $\endgroup$ – Jabberwock Oct 8 '17 at 16:42
  • $\begingroup$ Ah Ok something like setting in view3d context context.space_data.region_3d.view_matrix = context.scene.orientations["blah"].matrix.to_4x4() and orthogonal rotations of. $\endgroup$ – batFINGER Oct 8 '17 at 17:46
  • $\begingroup$ ... btw above will prob give wrong scale, would need only set rotation part of view matrix from orientation matrix. $\endgroup$ – batFINGER Oct 8 '17 at 17:58
  • $\begingroup$ @batFINGER, it looks like your snippet works, except that I think you have to invert the matrix. I'll do a little more testing and post an answer with a code example. $\endgroup$ – Jabberwock Oct 9 '17 at 2:27
1
$\begingroup$

Test script to put all 3d view areas in context screen into same orientation as first custom scene orientation

import bpy
from mathutils import Matrix
context = bpy.context
# put all view_3d areas in screen into screen.orientation[0]
scene = context.scene
screen = context.screen
orientation = scene.orientations[0]
view_rot = orientation.matrix.to_quaternion()

view3dareas = [a for a in screen.areas if a.type == 'VIEW_3D']
for a in view3dareas:
    r3d = a.spaces.active.region_3d
    r3d.view_rotation = view_rot

To make it change from camera perspective would need something like

    if r3d.view_perspective == 'CAMERA':
        r3d.view_perspective = 'PERSP'

To look "from above" from this orientation

rot = Matrix.Rotation(radians(-90), 3, 'X')
#view_rot = (rot * orientation.matrix).to_quaternion()
view_rot.rotate(rot)
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.