What is the Python command to check if current view is in orthographic or perspective mode? What is the python command to check if current view is in orthographic or perspective mode?
Region3D.view_perspective.

Get the space data of the 3D view area. A screen is split up into areas. The space associated with area is the active space.  The spaces 3d region has the view settings.

&gt;&gt;&gt; for i, a in enumerate(C.screen.areas):
...     i, a.type
...     
(0, 'PROPERTIES')
(1, 'CONSOLE')
(2, 'VIEW_3D')
(3, 'TEXT_EDITOR')

&gt;&gt;&gt; space = C.screen.areas[2].spaces.active


If we are sure we are in a 3d view (a panel there, an operator that polls there) then instead use

space = context.space_data


the property to change is view_perspective, in example below I am in perspective view

&gt;&gt;&gt; space.region_3d.view_perspective
'PERSP'


Tip A quick way to find the options available is crunch in something wrong.

&gt;&gt;&gt; space.region_3d.view_perspective = 'FOO'
Traceback (most recent call last):
  File "&lt;blender_console&gt;", line 1, in &lt;module&gt;
TypeError: bpy_struct: item.attr = val: enum "FOO" not found in ('PERSP', 'ORTHO', 'CAMERA')


Check if in ortho view.  Could also check if in camera view, is camera ortho

&gt;&gt;&gt; ortho_view = space.region_3d.view_perspective == 'ORTHO'


or perhaps (needs testing)

&gt;&gt;&gt; ortho_view = not space.region_3d.is_perspective


Set to ortho

&gt;&gt;&gt; space.region_3d.view_perspective = 'ORTHO'