Tips: Use an if-statement before UI creation

Hello everybody. Today I’m going you to share with you a tips about writing UI in MEL.

 

When you write an UI in MEL, and let’s say, you add a button to the window, and eventually execute it, your UI, if there be no syntactical mistake, will pop up. Then you need to add another button, regularly you close the window and add your textual line and rerun the script.

If you don’t close your window, and apply changes and call your script for an execution, you will see an error which reads:

// Error: line 1: Object’s name ‘testWindow’ is not unique. //

This error is very common that sometime it might transform your health into a headache.

The most common interlude of this error is in non-displayed windows. What do I mean?

If you execute the following code, your window will not popup, while the declaration of the window has happened, and only the button creation has encountered a problem, a syntactical problem.Try this code:

//

window -t “This is a test window” testWindow;

button testButton -w 100; // Note that this line is syntactically wrong, and errs.

showWindow mm;

//

In our button line, the second line is meant, we have made a wrong syntax which is unknown to Maya; therefore, Maya doesn’t understand it and breaks the execution process, which will result in no displaying of the UI.

But Maya has made a space in his memory allocation, and registered there a window with the node’s name “testWindow which will collide with recreation of the same window having the same name applied, if you change the name of your window everything calms down and your process comes routine, but is it really possible each time you change your window node’s name?

If you tell Maya if such name already exists, please delete, and the naturally Maya if the case be true will do that.

//

if (`window -exists testWindow`)

{

deleteUI testWindow;

}

//

Just place this script before any window declaration in any script, and then change the name in conditional statement to your window’s name.

our script will look like this:

if (`window -exists testWindow`)

{

deleteUI testWindow;

}

window -t “This is a test window” testWindow;

button testButton -w 100; // Note that this line is syntactically wrong, and errs.

showWindow testWindow;

//

 

 

I hope this tip come to be useful.

mostafatalebi@rocketmail.com

artixel.wordpress.com

What $ (Dollar) means in Regular Expressions?

When working with MEL, everybody knows that $ means to declare a variable, but when it’s included in a string what it does?

It simply check the strings(characters) before the dollar sign in the ending of the second strings.

Or as Jeffry Friedl mentions in his book:

The $ (Dollar) the position at the end of the line

Therefore let’s check the following script in MEL:

 

string $testString = “This is a test string”;

match “string$” $testString;

 

We have now learnt how to use $ in regExp!!

 

mostafatalebi@rocketmail.com

artixel.wordpress.com

 

 

MT Parenting Facilitator

tixel.wordpress.com
mostafatalebi@rocketmail.com

Image and video hosting by TinyPic

MT Parenting Facilitator
With this script you can do parenting (Both Constraint and regular parenting)

You have parent, zero out and unparent, so your process of controls’ placement
would be done so quicker than regular Maya process.

I have set several Constraint Options with a maintain option for you.

There is also two fields for child and parent which update in a runtime sequence.

artixel.wordpress.com
mostafatalebi@rocketmail.com

********************************************* I N S T A L L **************************************

Copy the .mel files into your script directory(usually: user/document/maya/version/script)

Warning: If you download the entire userSetup.mel file, it will replace a userSetup.mel which is already

in that folder(script directory) which might feed some plugins; I strongly recommend open the my userSetup.mel

and copy the content, and paste them into your scriptDirectory’s userSetup.mel.

Note: When copying it, be sure to hit enter and paste them in a new line. A letter change will result in script error.

Any question or request: mostafatalebi@rocketmail.com

artixel.wordpress.com

Download Link:

MT_ParentingFacilitator_2.0.0.0.rar

Or you can download it from CreativeCrash.com

http://www.creativecrash.com/maya/downloads/scripts-plugins/character/c/mt-parenting-facilitator