import bpy from bpy import context as C from mathutils import * sns=C.screen areas=sns.areas area=None for i in areas: if i.type=='VIEW_3D': area=i break spaces=area.spaces for i in spaces: if i.type=='VIEW_3D': space=i break region=space.region_3d vecz0=Vector( (0,0,1) ) vecz1=Vector( (0,0,1) ) vecz0.rotate( region.view_rotation ) maxv=max([abs(i) for i in vecz0]) idn=[abs(i) for i in vecz0].index(maxv) vecRst=Vector( (0,0,0) ) vecRst[idn]=-1 if vecz0[idn]>0:vecRst[idn]=1 region.view_rotation = vecz1.rotation_difference(vecRst)
本文摘自 :https://www.cnblogs.com/