Defining a procedure in userSetup.mel

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
  11 November 2010
Defining a procedure in userSetup.mel

Hi guys,
I'm trying to launch maya from the command line (via python) and have it run a procedure that I've put in userSetup.mel. The procedure is given the location of a txt file "mayafileList" so that it can do stuff with the contents of the text file.

So firstly.
I've put "userSetup.mel" in
C:\Documents and Settings\Me\My Documents\maya\2011\scripts\userSetup.mel
Is this the correct location for getting a mel script to run on startup? It appears to be running it because I'm getting syntax errors on my code (below).

This is the code for userSetup.mel


   proc Batch_Export (mayafileList, overw){ $f = 'fopen mayafileList "r"';
  while (!'feof $f'){ 
 string $source_url = 'fgetline $f';
 string $dest_url = 'fgetline $f';
 file -o $source_url;
 file -force -options "" -type "FileType" -pr -ea $dest_url' -prompt;
 }	
 fclose $f;
 }


I'm getting syntax errors for my procedure. Not the most helpful error either (no line number or description).

And the command line executed from a python script using os.system() so that I can pass it arguments is;

maya -command 'Batch_Export(mayafileList, overw);' -prompt



Any help would be appreciated,
I cant seem to fix the errors I get on Maya load

// Error: proc Batch_Export (mayafileList, overw){ //
// Error: Syntax error //
// Error: proc Batch_Export (mayafileList, overw){
//
// Error: Syntax error //
// Error: $f = 'fopen mayafileList "r"';
//
// Error: Syntax error //
// Error: while (!'feof $f'){
//
// Error: Syntax error //
// Error: string $dest_url = 'fgetline $f';
//
// Error: Syntax error //
etc

Last edited by AdamMax : 11 November 2010 at 05:05 AM.
 
  11 November 2010
Your main syntax error is in the main declaration,
proc Batch_Export  (mayafileList,overw)

remember this is mel, so you need to declare what these variable types are being passed, ie:
string $mayafileList,

It's a pain if you've been in Python having to remember the mel syntax
__________________
Founder & CEO : Red9Consultancy
Red9 StudioPack : Red9 StudioPack GitHub
Author: Autodesk Masterclass 2011 - 'Live Animation Binding'
 
  11 November 2010
Thanks Mark.
I'll try that out tomorrow. I'm completely new to mel, after coming from maxscript and python I'm finding the mel documentation rather... sparse.
 
  11 November 2010
i may be mistaken but can't you also make a usersetup.py file? and write your code in python if that is better for you...
__________________
"Who are you? I am the new number 2; Who is number 1? ... You are number 6; I am not a number, I am a free man!!!" the prisoner
 
  11 November 2010
Thanks for the help guys, I'm nearly there
Moving onto the next problem

I have the procedure defined on startup via userSetup.mel. The procedure basically loads the given file (an arg in the procedure) and exports it with a custom exporter type.

I start Maya from the command line with a -command which runs the procedure and passes in the file. However, it seams as if the custom exporter type is not valid
"// Error: Invalid file type specified: OurCustomExporter // "

If I then go down to the Mel command prompt in the very same session that was started above and run the same procedure again it works perfectly.

Could it be that the procedure is trying to export a file before our CustomExporter has had a chance to autoload? If so, how would I get around this? Is there a wait command in mel that I could throw into the beginning of the procedure?

Thanks for the help.
AdamM
 
  11 November 2010
Originally Posted by AdamMax: Could it be that the procedure is trying to export a file before our CustomExporter has had a chance to autoload? If so, how would I get around this? Is there a wait command in mel that I could throw into the beginning of the procedure?


Probably. Either call loadPlugin, or use evalDeferred to run the script when maya is next idle.
 
  11 November 2010
Smile

Thanks Robert..
loadPlugin blabla;
worked perfectly
 
  11 November 2010
Thread automatically closed

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.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
Thread Closed share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 08:44 AM.


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.