Notifications
                
            
                Clear all
    
            
        [Closed] Use Environment Background
May 23, 2011 3:58 pm
                      Hello,
I’m looking for a way to turn on/off  “Use Environment Background” chekbox using max script in Viewport Background dialog
I searched in maxscript help:banghead: but didn’t found how to make this
                             9 Replies                        
                    
                        
                        2 Replies
                    
                    it’s different.
as i understand it’s about [b][i]max background display toggle – Use Environment Background
[/i][/b]i have no idea how to use this flag. it might be obsolete.
May 23, 2011 3:58 pm
                      struct setEnvBgStr
(
	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
	),
	fn getButtonHwnd hnd =
	(
		for i in (windows.getChildrenHWND hnd) where matchPattern i[5] pattern:"use env*" do return i[1]
		0
	),
	
	fn UseEnvBGOn = 
	(
		local hnd = dialogmonitorops.getwindowhandle()
		setEnvBgStr.setCheckBoxState (setEnvBgStr.getButtonHwnd hnd) on
		uiaccessor.pressButtonByName hnd "OK"
		true
	),
	fn UseEnvBGOff = 
	(
		local hnd = dialogmonitorops.getwindowhandle()
		setEnvBgStr.setCheckBoxState (setEnvBgStr.getButtonHwnd hnd) off
		uiaccessor.pressButtonByName hnd "OK"
		true
	),
	fn useEnvBG state =
	(
		if environmentMap!=undefined do
		(
			DialogMonitorOPS.unRegisterNotification id:#useEnvBG
			DialogMonitorOPS.enabled = off
			DialogMonitorOPS.enabled = on	
			DialogMonitorOPS.RegisterNotification (if state then setEnvBgStr.useEnvBGOn else setEnvBgStr.useEnvBgOff) id:#useEnvBG
			max background
			DialogMonitorOPS.unRegisterNotification id:#useEnvBG
			DialogMonitorOPS.enabled = off
		)
	)
)
setEnvBgStr.useEnvBG on
--setEnvBgStr.useEnvBG off 
well this was fun
May 23, 2011 3:58 pm
                      This is perfect, thanks a lot I don’t know how you did it but my humblest appreciation Lo
May 23, 2011 3:58 pm
                      A word of warning:
When using DialogMonitorOPS, under some versions of max/windows, 3dsmax will give an error message when you close it (It will not crash unexpectedly or anything, but when you close it normally, it will give a message as though it had crashed).