Align View to Current Transform Orientation

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.

• 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). Commented Oct 8, 2017 at 16:42
• 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. Commented Oct 8, 2017 at 17:46
• ... btw above will prob give wrong scale, would need only set rotation part of view matrix from orientation matrix. Commented Oct 8, 2017 at 17:58
• @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. Commented Oct 9, 2017 at 2:27

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
for o in scene.transform_orientation_slots:
if o.custom_orientation:
orientation = o.custom_orientation

print("Using ", orientation.name)
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)