Posts Tagged ‘mel’

Maya : hos_rampColorShift.mel

Saturday, December 5th, 2009

Here’s another small function that i missed from my experience with Lightwave, it’s a script that allows you to shift the Hue, Saturation and Values of all color keys on the selected ramp node.
It has it’s own interface and i had to rewrite the RGB to HSV and the HSV to RGB code as the standard rgb_to_hsv and hsv_to_rgb functions clamp values to 0.0 and 1.0, which is a royal pain when your ramps are float and exceed 1.0 as value.

download : hos_rampColorShift_v1.0.zip

gradients_2

Maya : hos_invertRampPositions.mel

Saturday, December 5th, 2009

Here’s a small function that inverts all the key positions on the selected ramp, a small feature i missed from Lightwave and wanted to bring to Maya.

download : hos_invertRampPostions_v1.0.zip

gradients_1

Maya : Create Reference multifunctional hotkey

Saturday, December 5th, 2009

Here’s a small replacement for the default <CTRL> + <r> Create Reference command hot-key that adds some extra functionality.

This little function is actually quite simple, but allows one hot-key to do two things.
First, if nothing or a non referenced node is selected, the hot-key will simply function as Create Reference always did.
However, when a referenced node is selected, it will simply open up the Reference Editor.

Very simple, but a nice work-flow addition.

download : hos_ReferenceHotkey_v1.0

hosReferenceHK_01

Maya progressBar and interrupting a script loop

Tuesday, June 23rd, 2009

maya2009_120This seems to be a function that is forgotten by many MEL programmers but can save you a lot of headaches.

It is one of those things you might want to implement anywhere in a script you know will do some heavy looping that could take a lot of processing time.

Just add this to your script early on and you are able to interrupt your script by pressing ESC, and a as a bonus you can implement a progress bar for some visual feedback.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
global string $gMainProgressBar;
int $maxPBar = 10000;
progressBar -e -bp -ii 1 -max $maxPBar $gMainProgressBar;
 
for($i=0; $i &lt; $maxPBar; $i++)
{
    if(`progressBar -q -ic $gMainProgressBar`)
    {
        break;
    }
 
    // here goes you code
 
    progressBar -e -s 1 $gMainProgressBar; // increases the progress bar
}
 
progressBar -e -endProgress $gMainProgressBar; // call this when you stop the script or when the script is done

Offcourse, the counter isn’t really necesary, just adding this script without increasing the progressBar alone is enough to prevent you having to force quit Maya and losing your script when your script decides to take hours to finish.