SimplyMaya Forums

Welcome to the forum, feel free to ask questions here.


SM Forums / Maya Questions / Programming / Toggle Resolution Gate

Programming MEL Scripts, Expressions & Programming Related Topics

Join the conversation. Reply to post
 
Thread Tools
28-10-2011, 02:14 AM   #1
stwert
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.

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 .
Attached Files
File Type: txt ToggleResolutionGate.txt (804 Bytes, 428 views)
  Reply with quote
30-10-2011, 04:23 AM   #2
NextDesign
Technical Director
 
NextDesign's Avatar
 
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
__________________
Imagination is more important than knowledge.
  Reply with quote
30-10-2011, 01:53 PM   #3
stwert
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.
  Reply with quote
Reply

Thread Tools


Similar Threads
Thread Thread Starter Forum Replies Last Post
Texture resolution: a never ending story lecra Maya Basics & Newbie Lounge 2 24-12-2013 06:30 PM
Your New Year Resolution? calvert Maya Basics & Newbie Lounge 3 13-01-2010 03:35 AM
Resolution gate / render discrepancy? gubar Maya Basics & Newbie Lounge 2 22-01-2008 07:31 PM
XRay Toggle issues Tristanartform Maya Technical Issues 2 30-10-2007 02:17 AM
Resolution gate stretching.... drknow Maya Basics & Newbie Lounge 5 17-08-2003 01:29 AM