Maya for 3D Printing - Rapid Prototyping
In this course we're going to look at something a little different, creating technically accurate 3D printed parts.
# 1 28-10-2011 , 02:14 AM
EduSciVis-er
Join Date: Dec 2005
Location: Toronto
Posts: 3,374

Toggle Resolution Gate

It's always bugged me that you can't get a hotkey or shelf button for stuff like toggling the Resolution gate on and off. And it's a major pain with the hotbox too... Space > view > camera settings > resolution gate > release space.

So I figured out how to script a script to toggle the resolution gate on and off for the camera in the active panel. Hopefully it's helpful to someone else and let me know if there's bugs etc. I'm not that familiar with MEL yet, so I'm sure someone can break it handily. user added image

Can't upload .mel files, so just rename the extension after downloading. Better yet, just copy the code into the hotkey editor and setup a nice hotkey for it. I'm going to map it to one of my keyboard buttons user added image.

Attached Files
File Type: txt ToggleResolutionGate.txt (804 Bytes, 1014 views)
# 2 30-10-2011 , 04:23 AM
NextDesign's Avatar
Technical Director
Join Date: Feb 2004
Posts: 2,988
Hey Stwert, nice job for just beginning to figure out MEL!

Your script can be simplified a bit:

Code:
string $camera = "";

string $panel = `getPanel -wf`;

if (`getPanel -to $panel` == "modelPanel")
    $camera = `modelEditor -q -camera $panel`;

int $isResGateEnabled = `camera -q -displayResolution $camera`;

float $ratio = 1.0;

if ($isResGateEnabled) 
    $ratio = 1.0;
else 
    $ratio = 1.3;

camera -e -displayResolution (!$isResGateEnabled) -overscan $ratio $camera;
Only little changes. One thing I did was changed the logic to determine if the resolution gate is shown. I saved it into an integer, as it only ever returns 0 or 1. Using that, below I used the logical not operator, "!", to invert this. (1 -> 0, 0 -> 1). So when it's false, we make it true, and vice-versa. I also broke up the ratio into it's own separate variable and if statement. This allows the user to quickly change it, and also minimizes the chances that they might break something. It also allows you to edit the camera once, instead of twice; allowing you to be able to change that code later, and only change it once.

Nice job user added image


Imagination is more important than knowledge.
# 3 30-10-2011 , 01:53 PM
EduSciVis-er
Join Date: Dec 2005
Location: Toronto
Posts: 3,374
Nice, thanks... I wasn't striving for the most elegant solution, I was just thrilled it actually did the job, haha. Lots more to learn.

Posting Rules Forum Rules
You may not post new threads | You may not post replies | You may not post attachments | You may not edit your posts | BB code is On | Smilies are On | [IMG] code is On | HTML code is Off

Similar Threads