View Full Version : Installing and distributing scripts

02 February 2004, 09:41 AM

I'm currently putting together a set of melscripts for my co-workers to use. They are not as familiar with MEL, so I would like to make it as easy for them as possible to install the scripts i've been collecting/making.

Should i choose a popupwindow or a menu as a container for the scripts, which one is easier to install?

How do you distribute your scripts for easy installing?

How do a make a script so it installs itself without having to fiddle around with shelves?



02 February 2004, 12:22 PM
.How do a make a script so it installs itself without having to fiddle around with shelves?

What´s wrong with shelves? I personally favor the idea of putting all your tools on one shelf. The shelf, and the scripts, can be located on a network drive that is available to all users (by editing each user´s Maya.env file to point the scripts directory to the correct drive). This way no one has to copy the scripts locally, which makes it very easy to make updates. You might even want to edit the each user´s userSetup.mel file, such that every time they start Maya, the old tool shelf is deleted and a new one (with possible updates) is loaded automatically for them (ie, no fiddling ;) ). If you have button icons, you can also add this path to each user´s Maya.env file so the icons don´t have to be copied locally.

On a further note, my opinion is that shelves are an extremely efficient way of organizing different tool sets in Maya, and I would certainly encourage using this technique to people who are new to the software.

Of course, if you really want to add a menu to the main Maya UI, that´s also a very easy and effective approach (which I personally use as well) - just parent it to $gMainWindow. You´ll also have to add this to each user´s userSetup.mel file.

Not sure how this is handled at larger production studios, but I would assume it would be something like the way I´ve mentioned above.


02 February 2004, 02:28 PM
hehe.. I'm not negative towards shelves. It's just that I don't want my co-workers to build their own shelves for the scripts to work. Anyway...

The way you describe with shelves seems to be a good approach. I'll give it a try...


Anybody with a different approach?



02 February 2004, 02:49 PM
Tried it out... When i try to use the deleteShelfTab command it works great, but it needs the user to confirm the deletion which i don't really like. Do you know how to do this without any user interaction?

Maybe i should look into a way to do it through a menu...


02 February 2004, 03:18 PM
deleteUI -layout ($gShelfTopLevel + "|" + $shelfName);


02 February 2004, 04:36 PM
Thanks again...

Now I'm just trying to figure out how to check if a shelf is already present or not. Can't seem to figure it out... So if you by any chanse have this function laying around it would be most welcome...:)

Thanks anyway...


(BTW who's the guy on your avatar??? He :buttrock: ...)

02 February 2004, 05:10 PM
BTW who's the guy on your avatar???

That´s Bob (

Now I'm just trying to figure out how to check if a shelf is already present or not.

The `shelfLayout` command itself will do that. Also, the `layout` command can be used with any layout:

layout -q -ex $shelfName;

Additionally, the `addNewShelfTab` command will add a new shelf without necessitating any user input:

addNewShelfTab $shelfName;

That should be about it I guess. Have your company wire me the payment to my Swiss account. :)

02 February 2004, 10:52 PM
the method david described is pretty much what we use here, except that the userSetup file is put on the server along with all the other scripts. so everyone has the same userSetup.mel script run on startup.

its really quite a cool thing to do. in the userSetup script it also checks for a script called localUserSetup on the local drive, and sources that if it exists. So this way the user can still have custom startup scripts, but for the most part, everyone has the same.

oh, and checking to see if a shelf exists, you can also do it real easy like by just doing a control query command:

control -exists shelfName

so dave, how do you get one of those fan-dangled swiss bank accounts?

02 February 2004, 08:33 AM
the method david described is pretty much what we use here, except that the userSetup file is put on the server along with all the other scripts

I figured that was probably what most studios used. And having the userSetup on the network drive is ideal- the only catch being that if a user creates this file locally it could screw things up...but I guess if you tell everyone not to do this then it´s no big deal. So I guess the only thing you need to modify locally is each user´s Maya.env file.... which is a task that can also be automated via some lines of MEL (for example, using a master Maya.env file, then distributing it around via a `system (copy)` command (or whatever you like).

so dave, how do you get one of those fan-dangled swiss bank accounts?

Connections, my friend... good ole vitamin C. ;) BTW, where are you working?


02 February 2004, 09:08 AM
Thanks a lot for those replys!

I'm trying to get this up and running but that damn script won't run. Here's what i'm trying to run, do you see any direct errors:

global string $gShelfTopLevel;
string $ShelfName = "NAME";
int $ShelfExists = `control -exists $ShelfName´;

if ( $ShelfExitst = 1 )
deleteUI -layout ($gShelfTopLevel + "|" + $ShelfName);

loadNewShelf "shelf_TOOLS.mel";

saveAllShelves $gShelfTopLevel;

I get this when i run it:

// Error: int $ShelfExists = `control -exists $ShelfName´;
// Error: Line 3.47: Syntax error //

Such a simple thing should work, can't understand why... When i run the code control -exists $ShelfName it works just fine, but I can't get it into a variable... Damn damn damn...

02 February 2004, 09:28 AM

Found the error..... i used a ´ instead of a `in the end of that line... grrrr...

Thanks anyway...


02 February 2004, 09:38 AM
ok, i got it up and running, here's the final script if anyone wants it:

global proc UpdateShelf()

global string $gShelfTopLevel;
string $ShelfName = "Tools";
int $ShelfExists = `control -exists $ShelfName`;

// If a shelf with the name $ShelfName exists then delete it
if ( $ShelfExists == "1" )
deleteUI -layout ($gShelfTopLevel + "|" + $ShelfName);

// Load now shelf
loadNewShelf "shelf_Tools.mel";

//Save all shelves
saveAllShelves $gShelfTopLevel;

Thanks a bunch for the help David and Macaroni. The next thing would be to start testing this on my co-workers and getting that usersetup.mel up on a network drive...

Thanks again... :beer:


02 February 2004, 10:23 PM
Originally posted by dwalden74
the only catch being that if a user creates this file locally it could screw things up...don't quote me on this, but i'm pretty sure it doesn't matter if the user makes a userSetup file locally, because its over-ridden because the network path is searched before the local path. so if the user creates one, it just doesn't get executed. which is why you need the additional lines of code in the network userSetup.mel to source any local setup files that may exist.

Connections, my friend... good ole vitamin C. ;) BTW, where are you working?connections eh... sounds like i need to get me some.

i'm working at THQ's australian development studio, called funnily enough, thq studio australia. its a pretty new studio (i think we're about a year and a month old now). we're due to pump out our first title in another 4 months or so.

BarbaPappa: you're welcome for the help... even though most of it came from dave... :)

02 February 2004, 10:30 PM
we're due to pump out our first title in another 4 months or so.

So what's the name of this title (work with gaming myself)?

02 February 2004, 10:31 PM
its nothing too exciting. unless you're into kids games. ;) its the next jimmy neutron game. as far as kids platformers go thought, its going to kick ass. so if you know anyone with kids, get a copy of it for them when it comes out. :)

02 February 2004, 08:13 AM
i'm pretty sure it doesn't matter if the user makes a userSetup file locally, because its over-ridden because the network path is searched before the local path

I figured anything in the userScriptsDir would overwrite anything else, including userSetup.mel. I know if you copy Alias scripts (in /scripts/others, for example) to your local dir and modify them, these local versions are used in the Maya session and *not* the ones in /scripts/others any more. As you said, the network path is searched first, and scripts are here sourced, then comes the local path, and scripts are sourced again here, so if there were scripts with the same name, they would be effectively "overwritten" in Maya´s memory.....or something like that....


02 February 2004, 12:19 PM
Actually, I´m not sure about my above post regarding the userSetup.mel file.... you´d have to test it out to see how it behaves...

02 February 2004, 10:28 PM
you said, the network path is searched firstactually, my bad. what i meant was, that the network path is LISTED first in the path env variable (getenv MAYA_SCRIPT_PATH).

but anyway, i'm not quite sure how it all works.

it can't be a case of overwriting it in memory, because userSetup files are simply sourced - ie they are just commands stuck in a file that are executed, so there's nothing in memory to overwrite.

so yeah i don't really know how it works. maybe maya just has a flag that gets turned off once its sourced a userSetup file, so the first one it finds in the path gets run. i dunno... magic i guess. ;)

02 February 2004, 09:48 AM
I've been using this process for a while now, but when i recently checked the Shelf editor i saw quite a lot of shelfs named exaclty the same as the shelf i delete and replace every time i restart maya.

And for soem reason i can't delete more than one of them in the editor. I have to go into usersetup.mel and delete them there.

Is the delete command i'm using not the correct one or am i doing something wrong?

Here's the command i'm using that doesn't delete the shelf in Shelf editor:

deleteUI -layout ($gShelfTopLevel + "|" + $ShelfName);



02 February 2004, 09:59 PM
yeah I don't quite know what happens when you create a shelf, but there is a shelf file created and all that, so there's probably a lot more going on behind the scenes than just creating a piece of UI.

When I delete my shelves, I used a hacked version of the alias deleteShelf script - which just takes out the user confirmation to delete the shelf. I'm sure having a look in that script would tell you exactly what needs to happen to delete a shelf. If you wanted to know.

or you could be like me, and continue life in blissful ignorance as to the inner workings of shelves, and just hack the alias file. ;)

02 February 2004, 08:36 AM
Thanks again, I hacked the file and now it works perfect. Now I just gotta create some killer scripts for my co-workers... thanks again...


02 February 2004, 08:26 PM
Sorry to bump out in the conversation like that but I guess I take the opportunity to ask something related to the Maya env file..

how do you guy organize your script, personnaly it seems that what ever i put in that env file, only the script in the root of my script folder will work..
How come if I create a folder "test" (for exemple) in
C:\Documents and Settings\Administrateur\Mes documents\maya\5.0\scripts\

all the script in it won't work.

does maya as is own variable for the script folder or should I just copy the direction of the folder as it is up here..sorry sound probably dumb but I edit that env file in all the way i could and it never work ..

Anyway thanks for any help guy.


02 February 2004, 10:49 PM
I'm working on setting this up for our next project, and I have everything working just fine. The only issue I have is that after Maya starts up, when I check in the script editor to see if everything went smoothly, I see a bunch of (I'm talking like 12 or more!) warnings about the shelf I'm deleting and loading. Here is the message I get:

// Warning: The shelf "Ballers_2" already exists.
// Warning: The shelf "Ballers_2" already exists.

multiple times. The shelf loads off the network fine.

Is there a flag I can set somewhere that would suppress these warnings? or does someone have any idea as to why Maya is generating all these warnings?

I'm going to slap a print statement in the lading code to see if I can figure out where the loop is coming from.

Any input appreciated.

edit: I slapped a print statement in there and my command is only being called once........ hmmmm curious.:shrug:

02 February 2004, 10:51 PM
yeah, we get those warnings too... i've personally never given them a second thought, because everything works so smoothly. But if u find out how to get rid of it, please share. :)

02 February 2004, 11:02 PM
Well thats good to know, I'm not the only one seeing these warnings.

I slapped a couple of print statements at the beginning and end of my loadShelf proc and it appears that these warnings are being generated before my procedure is being called.

02 February 2004, 08:38 AM
I´ve seen this problem too, and I´ve got a sneaky suspicion it has to do with your optionVars not cooperating right with your delete shelf procs.

Check out deleteShelfTab.mel (/scripts/others) to see what´s really happening here: Maya deletes the layout- `deleteUI -layout ($gShelfTopLevel + "|" + $shelfName)` - but also updates your optionVars preferences. Actually, I think if you just copy-paste the chunk of code that´s in there into your own deleteShelf script (with maybe some minor changes) it should work fine.

Hope this helps-


02 February 2004, 09:14 AM
I use the method macaroniKazoo described earlier in this thread, and it works without warnings here. Can't say why it does work, but it does...


02 February 2004, 04:05 PM
I'm interested in doing this kind of thing when using the computers at my school. Whenever the computers are restarted, all the scripts and shelves I've added to the My Documents/maya/5.0 folder are reset to the default settings. I've been copy/pasting my stuff into this folder every time I'm in class (I'm in two different rooms twice a day, 4 days a week) and it's getting to be a bit annoying. I edited the Maya.env file to source the scripts from separate folders but could never get it to work (I used 3don's method from THIS THREAD ( The path is C:\Documents and Settings\login\My Documents\maya\5.0 and I can't figure out what I did wrong. Any help would definitely stop me from going grey!

-Bad Mange

02 February 2004, 05:12 PM
I use the method macaroniKazoo described earlier in this thread, and it works without warnings here. Can't say why it does work, but it does...

When you create a new shelf, or load an existing one, Maya is saving new option variables in your userPrefs. Check out the addNewShelfTab.mel in your scripts/others folder to see how this is done. Therefore, to completely rid Maya of a shelf, these optionVars will also have to be updated accordingly. BP, I´d say that if it works for you then great, but it might not work always like this.

ll the scripts and shelves I've added to the My Documents/maya/5.0 folder are reset to the default settings


You should check to see if this is a network limitation. I´ve had this exact same problem once on a network, where (due to user restrictions or something stupid) my prefs would not be saved locally among different Maya sessions.


02 February 2004, 05:41 PM
Here is what I figured out about the warnings.

Every time you close Maya it updates your userPref.mel file. In this file are all the references to the shelves that Maya is supposed to load on start up. For some reason, when you use the userSetup.mel to load in a shelf, it creates duplicate entries for that shelf in the userPrefs.mel file.

I figure it creates the duplicate entries because we are forcing Maya to load a shelf, and not allowing the error checking that occurs if you create a shelf normally. You know, you get that warning that says a shelf already exists with that name, if you try to create multiple shelves of the same name.

Also, I would figure that somewhere in the scripts that load a shelf, the optionVars are added to the userPrefs.mel. I didn't dig that far, because my solution works.

I fixed this problem by writting a procedure that removes the shelf entries from the userPrefs.mel file (see code below).

The header explains the usage of the proc. I have this procedure in the scripts folder on the network, and the last lines of my userSetup.mel on the network sources the script and calls it.

It removes ALL references to the shelfName you pass in from the userPrefs.mel. This is OK since we are deleting the shelf if it exists and loading it each time Maya starts.

I only do this because while I have been working on setting this pipeline up, I ended up with over 50 duplicate entries in my userPrefs.mel, so I had that many warnings popping up. And on each restart, the number kept going up

Here is the procedure:

procedure to remove entries for shelevs you specify in the userPrefs.mel file
this eliminates the Warning [shelfName] already exists that you get when loading
shelves through the userSetup.mel across a network. These warnings pop up because,
as near as I can figure, we are forcing Maya to load a shelf and bypassing the
normal error checking that goes on if you try to create a shelf with a duplicate name.

ABUSAGE: source and call the proc from the userSetup.mel file on the network, and pass
in a string that is the name of the shelf you want to remove from the

EXAMPLE: source mhRemoveShelvesFromOptionVars;
mhRemoveShelvesFromOptionVars "KillThisShelf";

global proc mhRemoveShelvesFromOptionVars(string $shelfToRemove)
//get the number of shelves stored in the optionVars
int $numShelves = `optionVar -q numShelves`;

//array to hold duplicate entries
string $duplicates[];
int $dupI = 0;
//get the duplicate shelf names into an array
string $testShelf = `optionVar -q ("shelfName"+$i)`;
if($testShelf == $shelfToRemove)
$duplicates[$dupI] = ("shelfName"+$i);
//now parse out the numbers from the shelf name returned above these are in the form
//"shelfName[N]" where [N] is a number
string $hold[];
int $holdI = 0;
string $temp[];
clear $temp;
int $numTokens = `tokenize $duplicates[$i] "shelfName" $temp`;
$hold[$holdI] = $temp[0];
//now lets delete all the shelf references
optionVar -remove ("shelfName"+$hold[$i])
-remove ("shelfLoad"+$hold[$i])
-remove ("shelfFile"+$hold[$i]);

//debugging statements
//print $duplicates;
//print $hold;

02 February 2004, 06:17 PM
David - there are restrictions on the computers mainly to prevent students from installing Kazaa and other such apps, but it prevents us from having saved preferences. Every program installed on every computer has a default setup, no matter what settings/prefs you save. But you have to restart the computer to reset the settings. Simply closing and reopening the app won't do it. Anyway, I saved the contents of the 5.0 folder to CD and copy/paste everything to the 5.0 folder everytime I'm at a new computer. I would like to set up my files the way BarbaPappa wants to do, so I can just copy one file to the directory and maya will get all my scripts, shelves, plugins and icons from a place on the network storage drive. Like I said before, I tried editing the Maya.env file just to organize my scripts/plugins/shelves/icons but it didn't work. This is what I had:

mpS_=%USERPROFILE%\My Documents\maya\5.0\scripts
mpP_=%USERPROFILE%\My Documents\maya\5.0\plugins
mpI_=%USERPROFILE%\My Documents\maya\5.0\prefs\icons
mpM_=%USERPROFILE%\My Documents\maya\5.0\prefs\markingMenus
mpV_=%USERPROFILE%\My Documents\maya\5.0\prefs\shelves

MAYA_SCRIPT_PATH = $mpS_\DPK;$mpS_\zoo;$mpS_\generi_rig;$mpS_\StopStaring;


XBMLANGPATH = $mpI_\generi_icons;$mpI_\dpk;$mpI_\zoo;

I had the folders for each set of scripts in the scripts folder, the icon sets in the icons folder, etc. So why didn't this work? I had the correct username for the computer I was on and everything. I don't know what the shelves and marking menus paths are, and a search in the Maya help didn't, um, help. What should the path be? And I'd like to have all the scripts on the network in one folder and just copy/paste the maya.env and/or userSetup file to the 5.0 folder for every computer I use (which is why I was interested in this thread) but I can't get the .env file to work.

-Bad Mange

EDIT: mhovland, I sent you a PM a few months back, did you ever get it?

02 February 2004, 07:44 PM
Here is a new issue I have come across.

I am trying to declare multiple script paths across the network like such:

MAYA_SCRIPT_PATH = \\emc01\Maya\scripts
MAYA_SCRIPT_PATH = \\emc01\Maya\prefs\shelves

I have tried it this way as well

MAYA_SCRIPT_PATH = \\emc01\Maya\scripts; \\emc01\Maya\prefs\shelves

And neither will work. I can't load my shelf out of the \prefs\shelves folder. The shelf will load as long as it is in the first network script path. Using "getenv "MAYA_SCRIPT_PATH" once Maya starts will return the multiple paths on the network, but Maya will only load and run scripts from the first network path.

Is this a bug anyone else has seen? It's not that big of a deal, I just wanted my shelves in a shelves folder and scripts in a scripts folder for neat and tidy management.

I can live with it only seeing one network script path if I have to, but I don't want to.

CGTalk Moderation
01 January 2006, 10:00 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.