View Full Version : getting the filename from fileBrowser.mel

11 November 2006, 03:49 AM
I'm having some difficulties with filehandeling....seems to be a plague of it going around...

I want to use fileBrower.mel script in SAVE mode (1) to allow the user to navigate to a directory and name a file for my procedure to write to...But I just can't capture the $filename from the fileBrowser proc.

I don't understand how to use the call back to fopen and write to the file my output..I can only get the hard coded $filename to work and not the fileBrowser....I've tried many ways....I just pasted it here for example....and to show that I had a callback procedure going...I get really close but the name is always a null string to the fopen, which fails....

proc pk_jointOutput(float $startFrame, float $endFrame, int $outputWS)
string $filename = ( `internalVar -userWorkspaceDir` + "exampleJO1.txt" );

//fileBrowser("fileCallback", "Save", "", 1);

int $fileHnd = `fopen $filename w`;

if($fileHnd == 0 )
error ("Unable to open output file " + $filename + " for writing");

.....calculations and fprints here.....

fclose $fileHnd;
pk_jointOutput(1, 3, 0);

11 November 2006, 10:41 PM
I got stupid of's just like every other button command in mel (I guess).

And thanks to Rob the Bloke for his mel file handeling bit on his web site...very helpful multi topic resource.

CGTalk Moderation
11 November 2006, 10:42 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.