View Full Version : output to text file

11 November 2006, 04:20 AM
can some one point me towards some tutorials online that explain the process of printing data to a text file. I checked the maya documentation but am looking for a littel more information.

11 November 2006, 06:35 AM
A good place to start would be the f1 mel documentation help docs, check out the fprint command and all other related commands. There are examples there to write out a simple text file.

What specific data are you trying to write?

12 December 2006, 10:49 PM
// Print a string into a file
$exampleFileName = ( `internalVar -userTmpDir` + "example.tmp" );
$fileId=`fopen $exampleFileName "w"`;
fprint $fileId "Hello there\n";
fclose $fileId;
If you want to do a hard return to a new line replace "\n" with "\n\r". And the "w" with an "a" (append).

Sick Spider
12 December 2006, 12:58 AM
Here is a simple one, takes every obj from a list of selected Obj' and print to a file,
u can take that and implement it as u need/want.

string $sel[] = `ls -sl`;
$myNew=`fopen ("c:/mySels.txt") "w"`;
for ($everSel in $sel)
fprint $myNew ($everSel+"\n");
fclose $myNew;

CGTalk Moderation
12 December 2006, 12:58 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.