Notifications
Clear all

[Closed] visual file export?

hello all, trying to create a file exporter with an interface. but failing miserably.

this is the script.

rollout exporter “multi-export” width:200 height:112
(
edittext infolder “inputfolder” pos:[8,8] width:184 height:23
edittext outfolder “outputfolder” pos:[8,40] width:184 height:24
button export “export files” pos:[8,72] width:184 height:32

on export pressed do
(
makedir outfolder

 local maxfilepattern = "D:\\projects\\steelbeasts\\" + infolder + "[\\*.max](file://\*.max)" 
 for filepath in getfiles maxfilepattern do
 ( 
      local filename = getfilenamefile filepath,
                  exportfilepath = "D:\\projects\\steelbeasts\	o_Al" outfolder + "\\" + filename + ".x"
    format "exporting %

” filepath
loadmaxfile filepath
exportfile exportfilepath #noprompt
)
resetmaxfile #noprompt
print “done.”

)
)
createdialog exporter
when i run it, i get an error message saying:

unable to convert: editTextcontrol:outfolder to type: filename

how do i make an editfilename dialog?

3 Replies

Try using the getSaveFileName function (check reference for the full syntax). It opens a dialog and returns the filename.

The reason it wasn’t working was because you were trying to use the rollout controls (outputfolder and inputfolder) as text strings. They are control objects not strings – however you can access the property ‘text’ in these objects that will yield the text inputted into the edittext field… i.e.

rollout exporter "multi-export" width:200 height:112
  
 
  	(
  	edittext infolder "inputfolder" pos:[8,8] width:184 height:23
  	edittext outfolder "outputfolder" pos:[8,40] width:184 height:24
  	button export "export files" pos:[8,72] width:184 height:32
  	
  	on export pressed do
  		(
  		makedir outfolder.text
  		
 		local maxfilepattern = "D:\\projects\\steelbeasts\\" + infolder.text + "\\*.max"
  		for filepath in getfiles maxfilepattern do
  			(
  			local filename = getfilenamefile filepath,
 			exportfilepath = "D:\\projects\\steelbeasts\	o_Al" outfolder.text + "\\" + filename + ".x"
  			format "exporting %
" filepath
  			loadmaxfile filepath
  			exportfile exportfilepath #noprompt
  			)
  		resetmaxfile #noprompt
  		print "done."
  		
  		)
  	)
  createdialog exporter

thanks, now it works

i’ll just read over your post a few times to figure what i did wrong, hehe.