Guest User

Home

a guest
May 18th, 2017
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.08 KB | None | 0 0
  1. import mathutils
  2.  
  3. viewmode = "none"        
  4. 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))
  5.                
  6. for area in bpy.context.screen.areas:
  7.     if area.type == 'VIEW_3D':
  8.         rv3d = area.spaces[0].region_3d
  9.         if rv3d is not None:
  10.             viewrot = area.spaces[0].region_3d.view_rotation*10000000
  11.             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") ]
  12.             for v, vm in vlist:
  13.                 if viewrot == mathutils.Quaternion(v):
  14.                     viewmode = vm
  15.             if viewmode == "TOP":
  16.                 rv3d.view_distance = 15 # This is the original distance to the zero point from Factory settings.
  17.             if viewmode == "FRONT":
  18.                 rv3d.view_distance = 15 # This is the original distance to the zero point from Factory settings.
  19.             if viewmode == "RIGHT":
  20.                 rv3d.view_distance = 15 # This is the original distance to the zero point from Factory settings.
  21.             if viewmode == "BOTTOM":
  22.                 rv3d.view_distance = 15 # This is the original distance to the zero point from Factory settings.
  23.             if viewmode == "BACK":
  24.                 rv3d.view_distance = 15 # This is the original distance to the zero point from Factory settings.
  25.             if viewmode == "LEFT":
  26.                 rv3d.view_distance = 15 # This is the original distance to the zero point from Factory settings.
  27.             if viewmode == "none":
  28.                 rv3d.view_distance = 15 # This is the original distance to the zero point from Factory settings.
  29.                 rv3d.view_matrix = view_matrix # This resets the location and rotation back to the initial view matrix values
  30.             viewmode = "none"
Advertisement
Add Comment
Please, Sign In to add comment