View Full Version : mel questions (please help)
ussmc 07-27-2006, 04:52 AM Hello all,
I'm new to scripting. I made my first script, it works, but please help:
- How come when Maya restarts, I have to execute it again. What do I have to do, to just type the name of the script on the command line then Enter to make it work?
- My script won't work when I add comments? (e.g. // ORIENT JOINTS. ETC. ETC. ETC)
- What's the script to snap pivot? (e.g. curve, snap or pivot snap to a joint)
|
|
hoisty
07-27-2006, 06:11 AM
from Maya's help:
Calling external procedures
If Maya encounters a command without a definition, it searches through the script paths for a MEL script with the same name as the command (minus the .mel extension on the file name).
If it finds the file, it declares all the global MEL procedures within that file, and if the procedure you called exists in the file, it executes.
For example, you have a file sayWhat.mel in one of the script folders with the following contents:
// This is a local procedure
// that is only visible to the code in this file.
proc red5() {print("red5 standing by...\n");}
// This is a global procedure. When this file
// is sourced, this procedure will become
// available.
global proc GoGo() {print("GoGo online\n");}
// This procedure has the same name as this file
// (without .mel on the end).
global proc sayWhat() {print("sayWhat online\n");}
Now if you try to call the function sayWhat on the command line:
Since there is no internal command sayWhat, Maya searches through all its script paths for a file called sayWhat or sayWhat.mel.
If it finds the file sayWhat.mel script in one of the script directories, it sources the contents of the file.
In this example, the global procedures sayWhat and GoGo are declared.
Maya checks whether a procedure with the name you tried to call exists in the file. If it does, Maya calls the procedure. In this example, a procedure named sayWhat exists in the file and so it executes and prints:
sayWhat online
Since the GoGo global procedure has been declared, you could now type GoGo in the Command Line or Script editor to execute the procedure.
ussmc
07-28-2006, 03:51 AM
Thank you for the mel info. Greatly appreciate it.
CGTalk Moderation
07-28-2006, 03:51 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
vBulletin v3.0.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.