ScriptSpot

Forum topic · Scripts Wanted

Update grid align to view

By mane162 · 2009-12-14

Description

Hello everybody, can you help me to make a script to:
I create a grid helper in max 2010,select the grid objetc, right click and align to view, but when you rotate the viewport you must select again "align to view".. the script must update automatically the grid alignment to viewport rotations.. really thanks for your help.

Comments (2)

Anubis · 2010-03-13

there is another version ;) (script attached)

Attachments

Graph · 2010-03-13

have phun


(
	-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
	-- - -- - -- - -- - -- - -- - -- - -- - -- - -- - -- - -- - -- - -- - -- - -- - -- - -- - -- - -- - -- - -- - -- - -- 
	--      --      --      --      --      --      --      --      --      
	---  brought --- to --- you --- by --- IN-Tools.biz --
	--      --      --      --      --      --      --      --      --      
	-- - -- - -- - -- - -- - -- - -- - -- - -- - -- - -- - -- - -- - -- - -- - -- - -- - -- - -- - -- - -- - -- - -- - -- 
	-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
 
	rollout grid2View "Align 2 View"
	(
		group ""
		(
			pickbutton pickGrid "Pick Object" width:(grid2View.width - 20) height:28 autoDisplay:true
			
			timer clock active:false
			spinner clockSpeed "Refresh Rate (s)" type:#Integer range:[1,60, 3] width:(grid2View.width - 20) align:#left
		)
		
		button start "Start Sync" width:(grid2View.width - 10) height:32 enabled:false
		
		on pickGrid picked obj do
		(
			if isValidNode obj do
			(
				start.enabled = true
			)
		)--END obj.picked
		
		on start pressed do
		(
			if pickGrid.object != undefined do
			(
				if isValidNode pickGrid.object do
				(
					clock.interval = clockspeed.value * 1000
					clock.active = true
				)
			)
		)--END start.pressed
		
		on clock tick do
		(
			if isValidNode pickGrid.object then
			(
				local viewTM = inverse (viewport.getTM())
				
		 		local pos = pickGrid.object.pos
				
				local nuTransform = viewTM
				
				nuTransform.row4 = pos
				
				pickGrid.object.transform = nuTransform
			)
			else
			(
				clock.active = false
				start.enabled = false
				pickGrid.object = undefined
			)
		)--END clock.tick
	)--END RO
	createDialog grid2View	
)