Notifications
Clear all

[Closed] Close dialog windows from maxscript

Wow…thanks for the help!

The new script works great, but one thing:

If I keep the true in the UIAccessor function, it doesnt process all the bad files in the specified directory.
However, once the true, else (false) is omitted, it goes through all the bad files that it opens, but of course the evaluation to boolean error is shown.

Edit: is there someway to handle different buttons of different error windows?
I have one error that just shows me an OK, but the next shows me OPEN/CANCEL.
Is there anyway to always get it to push OK or CANCEL, whichever is appropriate?

EDIT 2: actually, I found out why it does that the problem I said at the start…because of edit 1 heh. The window is not getting the proper button press because of the just default option, and the handler is never being stopped. So, it leads to the output only showing 1 error instead of 2.

Thanks again

no prob As for specific buttons, you can use ‘.pressButtonByName “OK”’, for example, to press the button labeled “OK”.

Oh and also (sorry to keep bugging you, I only started maxscript-ing last friday :P) when I omit the true/false stuff, it shows me the last error but puts a copy of it with the first error in the batch_file text file.

Ill show you:

With the first true/false in place the text file gives this:
C: ry\ChF_All_Heads.max
Window Title: 3ds Max
Window Body:
OK

     File Open Failed: C:	ry\ChF_All_Heads.max

Which is good, but it doesnt list the second error.

WithOUT the true/false in place the text file gives this:
C: ry\ChF_All_Heads.max
Window Title: Error message
Window Body:
OK

     your texture has a bad width or a bad height 

L:\Projects\Idol\0Trunk\Art\04_3D\Textures\Characters\Female\ChF_Head_0003_Skin_color.png

C: ry\ChF_All_Heads_max9.max
Window Title: Error message
Window Body:
OK

     your texture has a bad width or a bad height 

L:\Projects\Idol\0Trunk\Art\04_3D\Textures\Characters\Female\ChF_Head_0003_Skin_color.png

Both errors are listed; but the second error overlaps the first one for some reason.

oh… try moving the line…


				f_error = stringStream ""

From the handleBox function to just before the loadMaxFile line. The second error will ‘erase’ the first error otherwise (will adjust my post)

Hmm…now it just lists the first error, and if I take out the true/false, it just lists the filenames…troubles troubles

hmm. hold on… what ‘two errors’ are you getting, exactly?
Presumably if the max file won’t load, then that’s the only error you should be getting for a single file.
If the max file does load, but throws up a missing files error or so, then that’s technically not an error as far as 3ds Max is concerned…

Just trying to figure out what, exactly, is failing here

Hm, I think you’re right.

The first file, doesn’t load completely, and gives the file cannot be open error.

The second file, is missing png’s.
BUT, the UIAccessor handles it still…

Is there anyway to handle everything that’s thrown at it? Like every type of window that pops up, to close it and record what happened?

hmmm sure… basically just another print if the file did load, but dialogs -were- detected.


  global batch_file
  global f_error
  
  fn handleBox = 
  (
  	local windowHandle = DialogMonitorOPS.GetWindowHandle()
  	if (windowHandle != 0) then 
  	(
  		local title = UIAccessor.GetWindowText WindowHandle
  		format "	Window Title: %
" title to:f_error
  		format "	Window Body:
" to:f_error
  		local children = UIAccessor.getChildWindows windowHandle
  		for child in children do
  		(
  			format "		%
" (UIAccessor.getWindowText child) to:f_error
  		)
  		--local error = UIAccessor.GetWindowDllDescription WindowHandle
  		UIAccessor.PressDefaultButton()
  		true
  	)
  	else ( false )
  )
  
  rollout BatchRollout "Batch Export" width:341 height:158
  (
  	button btn15 "Source" pos:[13,13] width:96 height:24
  	button btn17 "Export" pos:[10,110] width:323 height:35
  	edittext edt11 "" pos:[121,13] width:206 height:24
  
  		fn getFilesRecurse dir =
  		(
  		
  			direc = GetDirectories (edt11.text + "\\*")
  			for d in direc do
  			(
  				join direc (GetDirectories (d+ "\\*"))
  			)
  
  			append direc (edt11.text + "\\") -- Need to include the original top level directory
  
  			maxfiles = #()
  			for de in direc do join maxfiles (getFiles (de + "*.max"))
  			
  			------------------
  			DialogMonitorOPS.unRegisterNotification id:#hello
  			-----------------
  			
  			for f in maxfiles do
  			(
  				DialogMonitorOPS.RegisterNotification handleBox id:#hello
  				DialogMonitorOPS.Enabled = true
  				
  				f_error = stringStream ""
  				if (loadMaxFile f == true) then
  				(
  					if (filePos f_error != 0) then (
  						format "%
" f to:batch_file
  						format "	ERRORS/WARNINGS WHILE LOADING:
" to:batch_file
  						format "%
" (f_error as string) to:batch_file
  					)
  					fname = getFilenameFile(f) + ".bin"
  					exportFile fname #noprompt
  					continue
  				)
  				else
  				(
  					format "%
" f to:batch_file
  					format "	FAILED TO LOAD:
" to:batch_file
  					format "%
" (f_error as string) to:batch_file
  				)
  			)		
  		)
  
  	on btn15 pressed do
  	(
  	source_dir = getSavePath()
  	edt11.text = (source_dir as string)
  	)
  	on btn17 pressed do
  	(
  		batch_file = createFile (edt11.text + "\\batchLog.txt")
  		getFilesRecurse edt11.text
  		close batch_file
  		DialogMonitorOPS.unRegisterNotification id:#hello
  		DialogMonitorOPS.Enabled = false
  	) 
  )
  createDialog BatchRollout 341 158
  

Which gives output (example):


  c:\zort\\fail.max
  	FAILED TO LOAD:
  	Window Title: 3ds Max
  	Window Body:
  		OK
  		
  		File Open Failed: c:\zort\fail.max
  
  
  c:\zort\\grass11.max
  	ERRORS/WARNINGS WHILE LOADING:
  	Window Title: Missing External Files
  	Window Body:
  		Continue
  		Browse
  		Don't Display This Message at Render Time
  

Note that this doesn’t actually list the missing external files; that specific dialog could be detected (check for the title) and the missing external files be gathered and added to the error string using some of the other 3ds Max functionality, though…

Edit: in fact, with newish 3ds Max versions, just use the “missingExtFilesAction:”[font=Verdana] and similar keywords, passing a by-reference variable that will get an array of the missing files (there’s others for XRefs, etc.). Much easie

Edit 2: Then again, that requires quiet mode – which supresses any of those other dialogs.
[/font]

Cool thanks man!

I just tried it, works perfectly.

(I had it working last night when I replaced the UIAccessor.pressdefaultbutton() with .closedialog windowHandle, but it displayed doubles on the file name error (but still showed the right error underneath) But this has no doubles at all

As for the listing of the dll’s that are missing, I dont think my version of 3DS Max (version 9) has the missingExtFilesAction command; it’s not in the reference. Unless its just not listed in there, too bad for me I guess

Really, thanks for all your help!

You’re welcome

As for that – it should be in there… it was added for 3ds Max 9. Check the topics:

  • Quiet Mode : most extensive documentation
  • 3ds Max File Loading and Saving : just a small reference
Page 2 / 3