Hi, I'd like to create an hotkey that toggles between an Orthographic persp Camera to a NonOrthographic.
When I do this manually from the Camera Attribute Editor the code recorded from the Sript Editor is:
setAttr "perspShape.orthographic" 0;
cameraCheckOrthographic "perspShape";
attrFieldSliderGrp -e -en false attrFieldSliderGrp11;
and when disabling the orthographic value:
setAttr "perspShape.orthographic" 0;
cameraCheckOrthographic "perspShape";
attrFieldSliderGrp -e -en true attrFieldSliderGrp11;
Now how an I make a Command in the HotKey Editor that when I press the assigned hotkey toggles the camera orthographic attribute to 0 or 1?
with my basic knowledge of Maya scripting I tried those two:
MEL(?):
$val = getAttr (perspShape.orthographic)
;
if ($val == 0) {$val = 1;}
else {$val = 0;} setAttr "perspShape.orthographic" $val;
cameraCheckOrthographic "perspShape";
attrFieldSliderGrp -e -en false attrFieldSliderGrp11;
Python(?):
val = getAttr "perspShape.orthographic";
if val == 0: setAttr "perspShape.orthographic" 0;
else: setAttr "perspShape.orthographic" 0;
cameraCheckOrthographic "perspShape";
attrFieldSliderGrp -e -en false attrFieldSliderGrp11;
But obviously they give mistakes.
I definitely want to learn scripting the proper way, but the topic is so vast that I would like to be adressed on where to start learining to solve this kind of problems.. any book or on-line source you would advise?
Even if you give the solution to my problem I think can be a very formative information to begin with.
I'd rather study Python because could be andy also in other software/situations.. but if you think is the wrong choice, pleae feel free to advise me otherwise.
Many Thanks,
Sergio