Export OBJ from Maya for UE4 : quick script

Here is a quick script I put together this morning,

It exports OBJs from Maya rotating so they are oriented correctly in UE4,

It has a nice file browser UI too!

// Adapted from:
// https://nccastaff.bournemouth.ac.uk/jmacey/RobTheBloke/www/mel/GUI_dialogs.html

// This procedure is called when the 'Open' button of the dialog is clicked.
// The procedure recieves the name of the file and it's extension
proc int onOk(string $dirpath,string $type) 
   string $path;
   string $name;
   $path = ($dirpath + "/");
   print("Path Set To: "+$path+"\n");
   // create a prompt dialog to request the users name
		string $result = `promptDialog 
			-title "Name The Asset"
			-message "Enter Name: (Dont put the extension)"
			-button "OK" -button "Cancel"
			-defaultButton "OK" -cancelButton "Cancel"
			-dismissString "Cancel"`;
	 	// if OK pressed
		if ($result == "OK") {
			// query the entry typed by the user
			$name = `promptDialog -query -text`;
			print("Exporting: " + $path + $name + "\n");
			select -all;
            rotate -r -os -fo 90 0 0 ;
            file -force -options "groups=1;ptgroups=0;materials=0;smoothing=0;normals=1" -type "OBJexport" -pr -ea ($path + $name);
            rotate -r -os -fo -90 0 0 ;
		else {
			print("Export Canceled\n");
   return true;

// The final parameter indicates the type of file dialog. 4=Folder Dialog
// The 1st parameter is a function to call when OK is pressed.
// The 2nd parameter is the text to appear on the OK button.
// The 3rd parameter is the type of file, somewhat meaningless here
fileBrowser( "onOk", "Text", "", 4 );