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 25-10-2004 , 06:33 AM
Lifire's Avatar
Registered User
Join Date: Oct 2004
Posts: 68

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.


"We don't actually need to know that the main character has a past. All we need to know is that he has an objective and a lot of people are going to die and a lot of innocent inanimate objects are going to be destroyed and blown up before he can complete that objective."
# 2 25-10-2004 , 10:10 AM
Alan's Avatar
Moderator
Join Date: Oct 2002
Location: London, UK
Posts: 2,800
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


Technical Director - Framestore

Currently working on: Your Highness

IMDB
# 3 25-10-2004 , 10:28 AM
Lifire's Avatar
Registered User
Join Date: Oct 2004
Posts: 68
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.


"We don't actually need to know that the main character has a past. All we need to know is that he has an objective and a lot of people are going to die and a lot of innocent inanimate objects are going to be destroyed and blown up before he can complete that objective."
# 4 25-10-2004 , 02:21 PM
kbrown's Avatar
Moderator
Join Date: Sep 2002
Location: London, UK
Posts: 3,198
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...)


Kari
- My Website
- My IMDB

Do a lot, Fail a lot and Learn a lot!
# 5 25-10-2004 , 07:38 PM
Lifire's Avatar
Registered User
Join Date: Oct 2004
Posts: 68
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?


"We don't actually need to know that the main character has a past. All we need to know is that he has an objective and a lot of people are going to die and a lot of innocent inanimate objects are going to be destroyed and blown up before he can complete that objective."

Last edited by Lifire; 25-10-2004 at 08:59 PM.
# 6 01-11-2004 , 05:20 AM
Lifire's Avatar
Registered User
Join Date: Oct 2004
Posts: 68
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?).


"We don't actually need to know that the main character has a past. All we need to know is that he has an objective and a lot of people are going to die and a lot of innocent inanimate objects are going to be destroyed and blown up before he can complete that objective."
# 7 01-11-2004 , 07:21 PM
kbrown's Avatar
Moderator
Join Date: Sep 2002
Location: London, UK
Posts: 3,198
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...


Kari
- My Website
- My IMDB

Do a lot, Fail a lot and Learn a lot!
# 8 01-11-2004 , 07:40 PM
Lifire's Avatar
Registered User
Join Date: Oct 2004
Posts: 68
Thanks kbrown.


"We don't actually need to know that the main character has a past. All we need to know is that he has an objective and a lot of people are going to die and a lot of innocent inanimate objects are going to be destroyed and blown up before he can complete that objective."
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