PDA

View Full Version : MEL - Sourcing Multiple Files ?


NocturnalTrance
06-02-2007, 05:16 PM
Hello guys!

Now, i'm currently putting this kick-ass MEL together that changes the standard Maya toolbox into something useful and pretty darn big. It's going to contain all the MEL commands we know and love, but not as seperate MELs, instead replacing the standard toolbox with everything intergrated to it.

Now, i'm not going to say why, but trust me, there is an idea behind doing this. I want to not have the tool procedures to be contained within the main MEL, nor have them all in one MEL. I need all tool scripts to be in their own seperate MEL file under a sub-folder. So that ONE tool is in ONE MEL, and all of these tool MELs are in the procedures folder (the procedures folder is a part of my mapping of this MEL application).

I've managed to get Maya to gather a filelist of all the MELs contained in the procedures folder and put it into an string array, BUT just HOW do i get Maya to source these arrays?

I've tried some different loops, but i can't get loops to work with the source command (i might be doing something wrong, haven't used loops all that much before).

Here is the code that will give you the string array of files contained in a specific folder,
i hope someone can tell me how to finished this section of my MEL application. The folder is fictional, you'll have to create that folder referenced in the string for it to work (that would be "../maya/x.x/scripts/myMEL", the "myMEL" folder doesn't exist by default, create it, put some MEL files in it and run the script)


string $userScriptDir = `internalVar -userScriptDir`; // string of path to script folder
string $melAppDir = $userScriptDir + "myMEL/"; // string of path to ../scripts/myMEL
string $melFileList[] = `getFileList -folder $melAppDir -filespec "*.mel"`; // get a list of files from specified folder (myMEL folder)

// just to check the code above, if i didn't mess up rewriting the code for this post,
// it should print an array of the mel files in the folder

print $melFileList;


as i said, this will only get a file list, but i need Maya to source these and NOT by writing each MEL file into the script, but having this file list be sourced automatically sourcing all the MEL files in the specified folder.

thanks in advance to those that put their heads into this and help getting this MEL application finished!

rendermaniac
06-02-2007, 08:33 PM
You don't need to do any of this. If you have a mel script with the same name as the MEL procedure in it, and they are stored in a directory that is in your MAYA_SCRIPTS_PATH (I think - don't have Maya on this machine) environment variable then they will autmatically be sourced when the function is called.

Simon

rendermaniac
06-02-2007, 09:47 PM
Alternatively you can use:

for ($script in $melFileList) {
eval("source "+$script);
}

If you are loading plugins then use evalDeferred() instead.Autosourcing makes it pretty redundant though.

Simon

NocturnalTrance
06-03-2007, 12:27 PM
sweet, this piece of code you wrote works like a charm!

Thanks buddy ;)

CGTalk Moderation
06-03-2007, 12:27 PM
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.