Notifications
Clear all

[Closed] createPreview batch style

Trying to create a tool that batch renders viewport previews. The problem is that Media Player opens and locks the _scene.avi temp file. If I turn off the AutoPlayPreview in the INI file it still pops up. If you manually change the options in preferences, it works. So, a couple of questions.

  1. Is there a way to specify the _scene.avi name before rendering?

Or

  1. Is there a way to “refresh” the preferences after changing the INI file?

An offline solution is to ask the user to change the preference before rendering. But I don’t like asking the user to do anything, because they don’t usually do it right.

Thanks in advance!


setINISetting (getMAXIniFile()) "Performance" "AutoPlayPreview" "0"

createPreview outputAVI:true percentSize:100 \
			start:animationRange.start.frame end:(animationRange.end.frame) skip:1 fps:framerate \
			dspGeometry:true dspShapes:false dspLights:false \
			dspCameras:false dspHelpers:false dspParticles:false dspBones:false \
			dspGrid:false dspSafeFrame:true dspFrameNums:true dspBkg:false

5 Replies

Any news on this?

I would also like to create a preview via maxscript. Because i use always the same settings. So i like to just click on a button to create a new preview…

No, my best solution is to ask the user to turn it off.


fn toggleAutoPlayPreview = 
(
	fn PreferenceCallback = 
	(
		fn setCheckBoxState hwnd state = 
		(	
			local BN_CLICKED = 0
			local BM_SETCHECK = 241
			local WM_COMMAND = 273
				
			local parent = UIAccessor.getParentWindow hwnd
			local id = UIAccessor.getWindowResourceID hwnd
				
			windows.sendMessage hwnd BM_SETCHECK (if state then 1 else 0) 0
			windows.sendMessage parent WM_COMMAND ((bit.shift BN_CLICKED 16) + id) hwnd	
			ok
		)
		hWND = DialogMonitorOPS.GetWindowHandle()
		
		if (UIAccessor.GetWindowText hWND) != "Preference Settings"  do return true
		bt = windows.getchildhwnd hWND "AutoPlay Preview File"

		act = (getIniSetting (getMAXIniFile()) #Performance #AutoPlayPreview) as integer
		setCheckBoxState bt[1] (act == 0)

		UIAccessor.SendMessageID hWND #IDOK
		true
	)

	DialogMonitorOPS.RegisterNotification PreferenceCallback id:#preferencesConfigure
	DialogMonitorOPS.Enabled = true	
	max file preferences
	DialogMonitorOPS.unRegisterNotification id:#preferencesConfigure
	DialogMonitorOPS.Enabled = false
	(getIniSetting (getMAXIniFile()) #Performance #AutoPlayPreview) as integer
)
toggleAutoPlayPreview()

You sir are a hero of heroes! I will study this.

here is probably more correct function that sets (not toggles) the AutoPlayPreview mode:

fn setAutoPlayPreview state enabled:off = 
(
	state = if state then 1 else 0
	local prev 
	fn PreferenceCallback &state:&state &prev:&prev = 
	(
		fn getCheckBoxState hwnd = 
		(	
			local BM_GETCHECK = 240
			windows.sendMessage hwnd BM_GETCHECK 0 0
		)
		fn setCheckBoxState hwnd act = 
		(	
			local BN_CLICKED = 0
			local BM_SETCHECK = 241
			local WM_COMMAND = 273
				
			local parent = UIAccessor.getParentWindow hwnd
			local id = UIAccessor.getWindowResourceID hwnd
				
			windows.sendMessage hwnd BM_SETCHECK act 0
			windows.sendMessage parent WM_COMMAND ((bit.shift BN_CLICKED 16) + id) hwnd	
			act
		)
		hWND = DialogMonitorOPS.GetWindowHandle()
		
		if (UIAccessor.GetWindowText hWND) == "Preference Settings" do 
		(
			if (bt = windows.getchildhwnd hWND "AutoPlay Preview File") != undefined do
			(
				if (prev = getCheckBoxState bt[1]) != state do state = setCheckBoxState bt[1] state
			)
			UIAccessor.SendMessageID hWND #IDOK
		)
		true
	)

	DialogMonitorOPS.RegisterNotification PreferenceCallback id:#preferencesConfigure
	DialogMonitorOPS.Enabled = true	
	max file preferences
	DialogMonitorOPS.unRegisterNotification id:#preferencesConfigure
	DialogMonitorOPS.Enabled = enabled
	prev == 1 
)
/*
setAutoPlayPreview on enabled:DialogMonitorOPS.Enabled 
setAutoPlayPreview off enabled:DialogMonitorOPS.Enabled 
*/

the function returns the previous state of AutoPlayPreview.