ScriptSpot

Forum topic · General Scripting

3dsmax Safe Frames Script

By coolankur49 · 2012-09-23

Description

Hi guys,

I am trying to develop a script to put custom values in 3dsmax title safe and action safe values.

I know how to toggle safe frames on and off but I do not know how do we..

1. turn on title safe and action safe check boxes
2. put custom values in the horizontal and vertical percent reductions

I read somewhere that this can be achieved with the help of dot net but since I have no knowledge about it, I'm totally relying on you guys to help me out.

Ankur

Attachments
Comments (6)

coolankur49 · 2012-09-23

Ok, I got it working somehow. This code switches to safe frame tab and switches on the Title safe, Action safe and Show Safe Frames in Active View checkboxes.

Please assist me now in setting the values of the spinners.


struct setSFStr
(
	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
		
	),
	--you can use strings: "Title Safe" or "Action Safe"
	fn getButtonHwnd hnd cbn:"Action Safe" = 
	(
		for i in (windows.getChildrenHWND hnd) where matchPattern i[5] pattern:cbn do return i[1]
		0
	),
		fn getButtonHwnd1 hnd1 cbn1:"Title Safe" = 
	(
		for i in (windows.getChildrenHWND hnd1) where matchPattern i[5] pattern:cbn1 do return i[1]
		0
	),
		fn getButtonHwnd2 hnd2 cbn2:"Show Safe Frames in Active View" = 
	(
		for i in (windows.getChildrenHWND hnd2) where matchPattern i[5] pattern:cbn2 do return i[1]
		0
	),
	fn sfTurnOn = 
	(
		local hnd = dialogmonitorops.getwindowhandle()
		local TCM_SETCURFOCUS = 0x1330
		for kidHWND in (UIAccessor.GetChildWindows hnd) where ((UIAccessor.GetWindowClassName kidHWND) == "SysTabControl32") do
			(	UIAccessor.SendMessage kidHWND TCM_SETCURFOCUS 2 0 )
		setSFStr.setCheckBoxState (setSFStr.getButtonHwnd hnd) on
		setSFStr.setCheckBoxState (setSFStr.getButtonHwnd1 hnd) on
		setSFStr.setCheckBoxState (setSFStr.getButtonHwnd2 hnd) on
		uiaccessor.pressButtonByName hnd "OK"
		true
	),
 
	fn setSF state =
	(
		DialogMonitorOPS.unRegisterNotification id:#useSF
		DialogMonitorOPS.enabled = off
		DialogMonitorOPS.enabled = on	
		DialogMonitorOPS.RegisterNotification (setSFStr.sfTurnOn) id:#useSF
		max vptconfig
		DialogMonitorOPS.unRegisterNotification id:#useSF
		DialogMonitorOPS.enabled = off
	)
)
setSFStr.setSF on

coolankur49 · 2012-09-23

Ok the code worked but we need to have the "Viewport Configuration" Dialog on "Safe Frames" TAB.

That's kind of weird as the script should switch to the appropriate TAB automatically.

And what about rest of the options I need. How do I change the spinner values.

coolankur49 · 2012-09-23

Thanks for the reply but I checked your code, its not working(max2012), neither the cgtalk link!

barigazy · 2012-09-23

Sorry but I use max2013 and not have later version for testing. Maybe someone else can help.

barigazy · 2012-09-23

Similar concept you can find on these thread where Rotem Shiffman (lo) explains how to turn on/off "Use Environment Background" chekbox
http://forums.cgsociety.org/showthread.php?f=98&=981677
I recreate this a little to produce same result but for toggling
Safe Frame checkboxes "Title Safe" anf "Action Safe"

struct setSFStr
(
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
),
--you can use strings: "Title Safe" or "Action Safe"
fn getButtonHwnd hnd cbn:"Title Safe" =
(
for i in (windows.getChildrenHWND hnd) where matchPattern i[5] pattern:cbn do return i[1]
0
),

fn sfTurnOn =
(
local hnd = dialogmonitorops.getwindowhandle()
setSFStr.setCheckBoxState (setSFStr.getButtonHwnd hnd) on
uiaccessor.pressButtonByName hnd "OK"
true
),

fn sfTurnOff =
(
local hnd = dialogmonitorops.getwindowhandle()
setSFStr.setCheckBoxState (setSFStr.getButtonHwnd hnd) off
uiaccessor.pressButtonByName hnd "OK"
true
),

fn setSF state =
(
DialogMonitorOPS.unRegisterNotification id:#useSF
DialogMonitorOPS.enabled = off
DialogMonitorOPS.enabled = on
DialogMonitorOPS.RegisterNotification (if state then setSFStr.sfTurnOn else setSFStr.sfTurnOff ) id:#useSF
max vptconfig
DialogMonitorOPS.unRegisterNotification id:#useSF
DialogMonitorOPS.enabled = off
)
)
setSFStr.setSF on
--setSFStr.setSF off