PDA

View Full Version : Calling external .exe, and drawing line


GameQ
08-30-2008, 04:14 AM
Sorry that this is such a dumb topic, but I cant find the answer any where. I'm a C/C++ programmer and have created a bunch of parsers that deal with .ma files. I'm sick and tired of clicking on and them and passing in the full file name of the .ma.

So I come here for your knowledge. I have read some tutorials on MEL scripting so don't need to learn the syntax, But I can not find a good documention of all MEL commands anywhere...

I need:

Command to save the scene.
Command that returns the full file name
Command to call an external .exe

my pseudo code would be something like:

proc parseFile
{
save_file();
$str = getFullPathName();
run("parser.exe "+str); //runs parser.exe with single command line argument str
}

Hell if someone just want to write out that proc for me, That be cool too!

hmmm, while I'm at...

I'm trying to use maya as a AI Path creator. Is there a way draw lines (preferably of different colors) from one object to another? Something like:

proc createAIPaths()
{
$selctedObjects[] = getAllSectedObjects();
if(selctedObjects != 2)
return; // get out, can only create a line between two objects
drawLine(selctedObjects[0], selctedObjects[1]);
}

haha, I bet the last line is alot more then just that! Thanks for any and all help. We programmer dudes don't know everything :)

~GameQ

Mgns
08-30-2008, 10:44 AM
i'll help you with the first part :)


// save
file -save;

// get the name
string $filename = `file -query-sceneName`;

// run
system( "parser.exe " + $filename );


there is a complete listing of the mel commands in the maya docs...

GameQ
08-30-2008, 04:01 PM
i'll help you with the first part :)


// save
file -save;

// get the name
string $filename = `file -query-sceneName`;

// run
system( "parser.exe " + $filename );


there is a complete listing of the mel commands in the maya docs...

thanks!

Where will it look to find parser.exe?

~GameQ

GameQ
08-30-2008, 08:14 PM
Problem:
when I type in:

internalVar -usd;

to the Script Editor, I get:

C:/Users/Quinn/Documents/maya/8.5/scripts/

This is the directory that I am saving all my .mel scripts to. One of these script is called:

qUI.mel

when I type in qUI into the command line in maya, I get:

// Error: Cannot find procedure "qUI".

Why?

~GameQ

kaymatrix
08-31-2008, 01:42 AM
bcos....

File is ready in the loc:
C:/Users/Quinn/Documents/maya/8.5/scripts/qUI.mel
But the file should contain a proc.... qUI()

Suppose if you placed the script after starting the maya.... then you have to execute "rehash"
rehash - will recheck all the script files available in your script directories.

one more thing.... qUI() proc must be global if its local then you have to source them separately each time before invoking the qUI(). Better put qUI as

global proc qUI()
{
}

most time .... ppls write scripts and save the file with the same main procedure name... so it will be easy to source and execute! But in few cases... you have to do manually!

GameQ
08-31-2008, 02:49 AM
Thanks kaymatrix, it was the global I was missing all along. Thanks for pointing that out!

~GameQ

ewerybody
09-01-2008, 09:07 AM
thanks!

Where will it look to find parser.exe?

~GameQ

System command will be executed at the current working directory!
You can retrieve that with the pwd-command.
And you can set it with chdir.

NaughtyNathan
09-01-2008, 09:32 AM
or alternatively:

system( "c:\\windows\\system32\\utils\\parser.exe " + $filename );

CGTalk Moderation
09-01-2008, 09:32 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.