This below should do the trick but ithink you will end up with having more information inside a line, for example the frame number as appendix.
//edit: edited your code you deleted some seconds ago
global proc mhFileOut()
{
global string $curObjectNodeType;
global string $outDirTxt;
global string $lvlOutList;
global string $lvlFileName;
global string $lvlFileName;
global string $lvlPrefix;
if (window -exists LvlOutWin)
{
deleteUI -window LvlOutWin;
}
string $lvlWindow =window -title "File Exporter v2.1" -width 200 -height 345
-sizeable 1 -tlc 150 150 LvlOutWin;
string $form = formLayout;
string $dirOutBut = button -width 150 -height 30 -label "Choose Output Directory" -c "getDestDirectory";
string $outTxt = text -label "Output Directory:";
string $outDirTxt = text -label "";
string $nameTxt = text -label "Name:";
// string $lvlFileName = textField;
string $controls[] = {(string(textField))};
string $expLVL = button -label "Export File" -height 34 -c "expLvlFile";
string $startText = text -l "frame start: ";
string $endText = text -l "frame end: ";
$controls[1] = intField;
$controls[2] = intField;
formLayout -edit
-af $dirOutBut "left" 2
-af $dirOutBut "right" 2
-af $dirOutBut "top" 5
-af $outTxt "left" 2
-ac $outTxt "top" 2 $dirOutBut
-ac $outDirTxt "top" 2 $outTxt
-af $outDirTxt "left" 2
-af $nameTxt "left" 2
-ac $nameTxt "top" 2 $outDirTxt
-ac $controls[0] "left" 2 $nameTxt
-ac $controls[0] "top" 2 $outDirTxt
-af $controls[0] "right" 2
-af $expLVL "left" 2
-af $expLVL "right" 2
-af $expLVL "bottom" 2
-ac $startText "top" 2 $controls[0]
-af $startText "left" 2
-ac $controls[1] "top" 2 $controls[0]
-ac $controls[1] "left" 2 $startText
-ac $endText "top" 2 $controls[0]
-ac $endText "left" 4 $controls[1]
-ac $controls[2] "top" 2 $controls[0]
-ac $controls[2] "left" 4 $endText
-af $expLVL "left" 2
-af $expLVL "right" 2
-ac $expLVL "top" 4 $startText
$form;
button -edit -command ("expLvlFile {\"" + stringArrayToString $controls "\",\"" + "\"}") $expLVL;
showWindow $lvlWindow;
}
////////////////////////////////////
// Get Destination Directory //
////////////////////////////////////
global proc string getDestDirectory()
{
global string $targetDirectory;
string $targetNtDirectory;
string $targetPathElements[];
int $i, $pathElementsCount;
fileBrowser "getTargetDirectory" "Choose Destination Directory" "directory" 4;
tokenize($targetDirectory,"/",$targetPathElements);
$pathElementsCount=size($targetPathElements);
for ($i=0;$i<$pathElementsCount;$i++)
$targetNtDirectory=$targetNtDirectory+$targetPathElements[$i]+"\";
return $targetNtDirectory;
}
///////////////////////////////
// Get Target Directory //
///////////////////////////////
global proc getTargetDirectory ( string $directory , string $type)
{
global string $outDirTxt;
global string $targetDirectory;
$targetDirectory=$directory + "/";
text -edit -label (""+$targetDirectory+"") $outDirTxt;
}
///////////////////////////
// Export the Level File //
///////////////////////////
global proc expLvlFile(string $controls[])
{
global string $curObjNodeType;
global string $lvlFileName;
global string $targetDirectory;
global string $lvlOutList;
global string $lvlPrefix;
//get the name of the file to be created
string $lvlFileNameTxt = textField -q -tx $controls[0];
$LvlFile = ($targetDirectory + $lvlFileNameTxt + ".wf");
int $startFrame = intField -q -v $controls[1];
int $endFrame = intField -q -v $controls[2];
string $objects[] = ls -sl;
$fileId = fopen $LvlFile "w";
for($i=$startFrame;$i<=$endFrame;$i++){
currentTime $i;
for($obj in $objects){
float $t[] = xform -q -worldSpace -translation $obj;
float $r[] = xform -q -worldSpace -rotation $obj;
fprint $fileId($obj + " " + $t[0] + " " + $t[1] + " " + $t[2] + " " + $r[0] + " " + $r[1] + " " + $r[2] + "\n");
};
};
fclose $fileId;
}