Simply Maya User Community

Simply Maya User Community (https://simplymaya.com/forum/index.php)
-   Maya Basics & Newbie Lounge (https://simplymaya.com/forum/forumdisplay.php?f=31)
-   -   MEL script help (https://simplymaya.com/forum/showthread.php?t=14079)

Lifire 25-10-2004 06:33 AM

MEL script help
 
I downloaded a reference plane script...

"Description: this script creates polygon planes with reference images for top, side and front views. Leave the image file name blank if you don't wish to create that plane.

Installation: Extract the zip in your "My Documents/maya/scripts" folder and type "refplanes;" in the command line (or make a shelf button)."

I was attempting to create a shelf button, but after I select the input section and save to shelf, the script doesn't work. When it is clicked it doesn't bring up the dialog box. The only way I can get it to work is through the command line. Any ideas?

Thanks.

Alan 25-10-2004 10:10 AM

you probably dont have it sourced properly try this in your shelf button:

source "/path/to/your/script.mel/"
name_of_the_function

Then drag that to the shelf and try that.

Alan

Lifire 25-10-2004 10:28 AM

I'm not sure exactly what you mean, but I tried variations of what you gave me, and they lead to errors every time. I read in the Maya help that to create a shelf icon for the script you slect the input text (bottom of script editor) then save to shelf.

So, I open the script through the script editor and it displays the code in the input section, and I select that text and save to shelf. The icon doesn't work, and it's odd because it doesn't execute from the script editor either. The only way I have gotten it to work so far is through the command line.

Thanks again.

kbrown 25-10-2004 02:21 PM

You don't put the whole mel script on the shelf. Just save the script in your scripts folder. Open up the script editor. Type these lines in:

source refplanes.mel;
refplanes;

Select the two lines and MMB drag drop them on to your shelf.

(As a matter of fact the first line there is optional...)

Lifire 25-10-2004 07:38 PM

Thanks! I just assumed that it was all of the code because, for example if you create a sphere, and copy the code from the script history and save to shelf that's what it will do.

Edit: That method worked for the refplanes script, but I tried that for an X-Ray script and it says, "error cannot find xray.mel for source statement." But if I select all of the code from the script editor and save to shelf it works like that. The two scirpts seem opposite.

Also, there are 2 folders for scripts, one in the 6.0 folder and another in the default my documents maya folder, which would I put the scripts in?

Lifire 01-11-2004 05:20 AM

Anyone know why one script would work like this:

source refplanes.mel;
refplanes;

but not work when saving all of the code to shelf, and another script would work by saving the code to shelf but not by saving the command name to shelf? Why would they be opposite and how can I make the latter of these work by just saving the command name to the shelf?

See example above. The xray.mel script gives me an error when trying to use the command name (script name?).

kbrown 01-11-2004 07:21 PM

It is because a more complex script is written in procedures and simple shelf buttons are just a list of mel commands or calls to other mel scripts.

In the refplanes.mel case there is a procedure which creates the graphical user interface (GUI) for the script. Then there are several other procedures which carries out the required tasks when the user clicks a button for example.

This is why you save only the refplanes; command to the shelf. It simply calls the entry point of the script (which creates the GUI). The GUI itself knows how to call the other procedures in the script.

A simple shelf button which only prints "Hello world" or toggles x-ray view on and off does not require this kind of procedural structure so it's easier to save it all inside the shelf button itself...

About your folder question. In general, if you know a script works with all versions of Maya, then you should put it in the My Documents/Maya/Scripts folder. If the script only works in Maya 6, you should put it in the other (version specific) folder...

Lifire 01-11-2004 07:40 PM

Thanks kbrown.


All times are GMT. The time now is 02:46 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Simply Maya 2018