Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import mathutils
- viewmode = "none"
- view_matrix = ((0.41, -0.4017, 0.8188, 0.0), (0.912, 0.1936, -0.3617, 0.0), (-0.0133, 0.8959, 0.4458, 0.0), (0.0, 0.0, -14.9892, 1.0))
- for area in bpy.context.screen.areas:
- if area.type == 'VIEW_3D':
- rv3d = area.spaces[0].region_3d
- if rv3d is not None:
- viewrot = area.spaces[0].region_3d.view_rotation*10000000
- vlist = [ ((10000000.0000,-0.0000,-0.0000,-0.0000), "TOP"), ((7071067.5000, 7071067.5000, -0.0000,-0.0000), "FRONT"), ((5000000.0000, 5000000.0000, 5000000.0000, 5000000.0000), "RIGHT"), ((0.0000, 10000000.0000,-0.0000,-0.0000), "BOTTOM"), ((0.0000,-0.0000, 7071067.5000, 7071067.5000), "BACK"), ((5000000.0000, 5000000.0000,-5000000.0000,-5000000.0000), "LEFT") ]
- for v, vm in vlist:
- if viewrot == mathutils.Quaternion(v):
- viewmode = vm
- if viewmode == "TOP":
- rv3d.view_distance = 15 # This is the original distance to the zero point from Factory settings.
- if viewmode == "FRONT":
- rv3d.view_distance = 15 # This is the original distance to the zero point from Factory settings.
- if viewmode == "RIGHT":
- rv3d.view_distance = 15 # This is the original distance to the zero point from Factory settings.
- if viewmode == "BOTTOM":
- rv3d.view_distance = 15 # This is the original distance to the zero point from Factory settings.
- if viewmode == "BACK":
- rv3d.view_distance = 15 # This is the original distance to the zero point from Factory settings.
- if viewmode == "LEFT":
- rv3d.view_distance = 15 # This is the original distance to the zero point from Factory settings.
- if viewmode == "none":
- rv3d.view_distance = 15 # This is the original distance to the zero point from Factory settings.
- rv3d.view_matrix = view_matrix # This resets the location and rotation back to the initial view matrix values
- viewmode = "none"
Advertisement
Add Comment
Please, Sign In to add comment