VIEWPORT AUTO SNAP HELP ?

i try to develop a script , it can auto detect viewport , i try but it not work , can you help me , sorry my bad english

fn autosnap =
(
global ar = #("view_top","view_bottom","view_right","view_left","view_front","view_back" )
global hr =viewport.getType() as string
snapMode.active = true
for i in 1 to ar.count do
(

if hr != ar[i] then
snapMode.type = #3D
else
snapMode.type = #2_5D
)
)

registerRedrawViewsCallback autosnap
unRegisterRedrawViewsCallback autosnap

Comments

Comment viewing options

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

Thank

You save my day :)

miauu's picture

.

Try this:

(
	global gloVar_AutoVptSnapChange
 
	fn gloVar_AutoVptSnapChange =
	(
		function SetSnapTo2_5D =
		(
			if snapMode.type != #2_5D do snapMode.type = #2_5D
		)
 
		vptType = viewport.getType()
		if snapMode.active != true do snapMode.active = true
		case vptType of
		(
			#view_left: (SetSnapTo2_5D())
			#view_right:  (SetSnapTo2_5D())
			#view_back:  (SetSnapTo2_5D())
			#view_front:  (SetSnapTo2_5D())
			#view_bottom:  (SetSnapTo2_5D())
			#view_top:  (SetSnapTo2_5D())
			default:  (if snapMode.type != #3D do snapMode.type = #3D)
		)
	)
 
	unRegisterRedrawViewsCallback gloVar_AutoVptSnapChange
	registerRedrawViewsCallback gloVar_AutoVptSnapChange
)

Comment viewing options

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