0
$\begingroup$

How to ... ... toggle views with the opposite 3d space viewing side ?

e.g.

press key for front view and press again for back view


An half solution is to reuse the same hot key.

  • This method has the benefit of quickly reviewing the front and back side. You can keep the hot key pressed to see one side and press shift to see the other side and release shift to go back to the other view.

  • Another half solution might be to assign double click (possible with keyboard key) to go to the complementary side view.


When these half solutions work fine the operation still seems a bit complicated.

$\endgroup$
2
  • 2
    $\begingroup$ Why do you want to "re-invent the wheel"? In the default UI, to see the front view, one presses the "1" key on the numeric keypad; to see the opposite (back) view, one presses "CTRL-1" key on the numeric keypad; to see the top view, one presses the "7" key on the numeric keypad; to see the opposite (bottom) view, one presses "CTRL-7" key; and to see front right, one presses the "3" key on the numeric keypad; to see the opposite (left) view, one presses "CTRL-3" key . $\endgroup$
    – brasshat
    Commented May 7, 2017 at 1:07
  • $\begingroup$ In short, some key positioning doesn't work for me. And I do not try to reinvent the wheel. It's better in general to stick to default. I'm changing some keys (not all) for my work flow. (For further notice see also my last few comments at blender.stackexchange.com/questions/78960/… ) $\endgroup$
    – odn
    Commented May 7, 2017 at 13:32

1 Answer 1

2
$\begingroup$

It is script chenge view to the opposite

enter image description here

import bpy
from bpy_extras import view3d_utils
from mathutils import Vector

def getView(self, context, event):
    region = context.region
    rv3d = context.region_data
    #coord = event.mouse_region_x, event.mouse_region_y
    #view_vector = view3d_utils.region_2d_to_vector_3d(region, rv3d, coord)
    return rv3d.view_rotation * Vector((0.0, 0.0, -1.0))

def findView(self, context, event):
    vector = getView(self, context, event)
    if vector == Vector((0.0, 1.0, 0.0)):
        bpy.ops.view3d.viewnumpad(type='BACK', align_active=False)
    elif vector == Vector((0.0, -1.0, 0.0)):
        bpy.ops.view3d.viewnumpad(type='FRONT', align_active=False)
    elif vector == Vector((1.0, 0.0, 0.0)):
        bpy.ops.view3d.viewnumpad(type='RIGHT', align_active=False)
    elif vector == Vector((-1.0, 0.0, 0.0)):
        bpy.ops.view3d.viewnumpad(type='LEFT', align_active=False)
    elif vector == Vector((0.0, 0.0, 1.0)):
        bpy.ops.view3d.viewnumpad(type='TOP', align_active=False)
    elif vector == Vector((0.0, 0.0, -1.0)):
        bpy.ops.view3d.viewnumpad(type='BOTTOM', align_active=False)


class ModalOperator(bpy.types.Operator):
    """swich view to opposite"""
    bl_idname = "object.modal_operator"
    bl_label = "Simple Modal Operator"

    def invoke(self, context, event):
        findView(self, context, event)
        return {'FINISHED'}



def register():
    bpy.utils.register_class(ModalOperator)


def unregister():
    bpy.utils.unregister_class(ModalOperator)


if __name__ == "__main__":
    register()
$\endgroup$
1
  • $\begingroup$ If you want I can edit it was a ready addon $\endgroup$ Commented May 6, 2017 at 20:49

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .