stl with importFile - Changing settings

I have written script that imports and renders sequences of stl files that I generated in an external program. I use importFile to read in the stl files. When I use the #noprompt option it always uses the default settings rather than my previously used settings (even though without #noprompt the dialog box always contains my most recent settings). Using the default settings is not an option for me as my stl data contain a large amount of fine detail that is smoothed out and eliminated when using the defaults, but imports correctly when using Quick Weld and unchecking Auto Smooth. I am loading a sequence of 1000 files and so pushing enter for each one is a pain in the neck!

Does anyone know how I can either change the default settings or specify my own settings as an option in the importFile command when importing stl files?

I have seen this problem mentioned before, but have never seen a satisfactory solution and so if anyone knows of a solution I would be very grateful.


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
pixamoon's picture


you can use UIAccessor.PressDefaultButton()

take a look on sample here (by RustyKnight)

I don't know how .stl import window looks. But if you need just press default button - just do import without #noprompt, it will keep your previous settings and UIAccessor will press Yes button.

s.neethling's picture


Thank you very much. While it doesn't work using the default button (for some unknown reason "OK" wasn't set as the default button), I did slightly modify that code to press the "OK" button.

In case anyone else is interested, the code that I used to load the sequence of stl files and save them as max files is follows. I have done one load outside the loop so that the default values can be set followed by the rest of them inside the loop with the UIAccessor pressing the button for me:

start = 0
finish = 1000
inputpath = "D:\\SPH Simulations\\3D box fill\\stl\\"
outputpath =  "D:\\SPH Simulations\\3D box fill\\pictures\\max\\"
inputfileroot = "data_surf_C1_"
inputscenefile = "D:\\SPH Simulations\\3D box fill\\Water Flow Base (3ds max).max"
fn mf = (
	local windowHandle = DialogMonitorOPS.GetWindowHandle()
	if (windowHandle != 0) then (
		local title = UIAccessor.GetWindowText WindowHandle
		if (title == "Import STL File") then (
			WindowHandle = DialogMonitorOPS.GetWindowHandle()
			UIAccessor.PressButtonByName WindowHandle "OK"
	return true
fn savestlasmax num = (
	--load rest of scene
	loadMaxfile inputscenefile
	--my input file numbers are padded with leading zeros
	file_number = formattedPrint num format:("06u")
	file_to_open = inputpath+inputfileroot+file_number+".stl"
	importFile file_to_open
	--apply material property to input geometry
	$.material = meditMaterials[1]
	modPanel.addModToSelection (Uvwmap ()) ui:on
	file_to_save = outputpath+"flow"+num as string+".max"
	savemaxfile file_to_save
DialogMonitorOPS.unRegisterNotification id:#eyeInTheSky
--do one load and save outside dialog monitoring so that default values can be set
savestlasmax 0
DialogMonitorOPS.RegisterNotification mf id:#eyeInTheSky
DialogMonitorOPS.Enabled = true
for render_count = start+1 to finish do
	savestlasmax render_count
DialogMonitorOPS.unRegisterNotification id:#eyeInTheSky
DialogMonitorOPS.Enabled = false

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.