Hello everyone!
I was looking for a way to toggle the
default camera from perspective to orthogonal view (not locked),
similarly to what you would do in Zbrush or 3DS Max (which is very handy
for modeling in my opinion).
I saw a copule of
posts here in the forum but none of the suggestions ticked all the
boxes for me so I came up with a little script and I thought it could
turn out to be usefull to other people as well, so here it is:
///////////////////////////// Orthogonal camera toggle /////////////////////////////
// Script by Giacomo Colivicchi (AKA R3D)
//
// The script enables orthographic mode for the default persp camera
// and in order to avoid camera roll (which will happen if you pass your point
// of focus' zenith) locks its z axis.
//
// Optionally you can delete the double slash before "FrameSelectedWithoutChildren"
// to enable framing on the currently selected item
//
// Enjoy! :D
$cameraState = `camera -q -o persp`;
if ($cameraState < 1) {
setAttr "perspShape.orthographic" 1; //enables orthographic mode
setAttr -lock true "persp.rz"; //locks the z axis to avoid camera roll
tumbleCtx -e -orthoLock false tumbleContext; //enables tumbling in orthographic mode
tumbleCtx -e -autoOrthoConstrain false tumbleContext;
// FrameSelectedWithoutChildren; //optional: remove double slash to frame selected
} else {
setAttr "perspShape.orthographic" 0; //disables orthographic mode
setAttr -lock false "persp.rz"; //unlocks the z axis
tumbleCtx -e -orthoLock true tumbleContext; //reset tumbling options to default behaviour
tumbleCtx -e -autoOrthoConstrain true tumbleContext;
// FrameSelectedWithoutChildren; //optional: remove double slash to frame selected
}The script is super basic (I'm new to scripting) but it gets the job done.
The
annoying thing with Maya's ortho view (as already pointed out in this
post:
https://bit.ly/2mQ95AA) is that if you pass your model's zenith
the camera looses it's orientation. To be more precise the Z axis will
start rotating as well.
To counter this issue the script locks the camera's z axis.
Enjoy!

Replies
Thanks very much!
It helps to know a little bit about programming cause sometimes you got to coax chatgpt through things in a guided way, but it's pretty handy for this sort of thing.
Here is a revised version. This should work correctly:
// Orthogonal Camera Toggle -------------------------------------------------------------------------------------------------------------------------- // // Script by Giacomo Colivicchi (AKA R3D) // // // The script toggles the default persp's camera ortho/persp mode and enables tumbling so that you can not only move, but also freely rotate in // orthogtraphic mode. To avoid unwanted tilting around the Z axis (Camera Roll), which happens if you pass your focus point's zenith, the Z axis // is locked temporarily. // // Run the script once again to restore the camera to it's default perspective mode. // // // Enjoy! :D // // global proc j_togglePerspMode() // Description: // Toggles orthographic mode for the defauld "persp" camera. // // Arguments: // None. // // Returns: // None. // // { int $cameraState = `camera -query -orthographic persp`; if ($cameraState < 1){ setAttr "perspShape.orthographic" 1; setAttr -lock true "persp.rz"; tumbleCtx -e -orthoLock false tumbleContext; tumbleCtx -e -autoOrthoConstrain false tumbleContext; } else { setAttr "perspShape.orthographic" 0; setAttr -lock false "persp.rz"; tumbleCtx -e -orthoLock true tumbleContext; tumbleCtx -e -autoOrthoConstrain true tumbleContext; } } j_togglePerspMode;Have a nice day!