ScriptSpot

Forum topic · General Scripting

Hide / unhide balls in time

By azardei · 2011-09-14

Description

Hi,

I am trying to hide balls with reference to time and then unhide them, animate dose not work with hide , can you propose another way of doing it ?

Comments (4)

azardei · 2011-09-15

I have solved it with

for o in geometry do
(o.visibility = bezier_float()
with animate on
(
at time 0 o.visibility.controller.value = 0
at time 100 o.visibility.controller.value = 1
)
)

tassel · 2011-09-15

I started on making a script to do this once upon a time ;o)
It's not finnished, but here it is anyway:


try(destroyDialog roll_VisibilityDialog) catch()
		-----------------------------------------------------------------------------
		-- Function (with animate on)
		----------------------------------------------------------------------------- 
	(
		fn fn_AddVisKey Obj Val =
		(
			VisTrack = obj.visibility.controller
			with animate on
			(
				newKey = addNewKey VisTrack currentTime #select
				newKey.value = Val
			)
		)
		
		rollout roll_VisibilityDialog "Vissibility On/Off V1.0"
		(
			-----------------------------------------------------------------------------
			-- UI STUFF
			----------------------------------------------------------------------------- 
			group "Object Visibility:"
				(
					button btn_VisOn "..:: ON ::.." width:85 height:30 align:#left across:2
					button btn_VisOff "..:: OFF ::.." width:85 height:30 align:#right
					button btn_DelVisKey "Delete Keys On Selected Objects" width:175 height:40 align:#center
					
					slider sld_VisSlide "Visibility" width:175 height:30 range:[0,1,0]
				)
			-----------------------------------------------------------------------------
			-- Visibility Slider 
			----------------------------------------------------------------------------- 
			on sld_VisSlide changed val do
			(
				for obj in selection do 
					(
						if obj[1].controller == undefined do obj.visibility = bezier_float()
						obj[1].controller.value = val
						
						--registerRedrawViewsCallback "Lage en Function" (sld_VisSlide)
						--RedrawViews() 
					)
			)
			-----------------------------------------------------------------------------
			-- Visibility OFF
			----------------------------------------------------------------------------- 
			on btn_VisOff pressed do
			(
				if selection.count >= 1 then
				(
					undo on
					(
						for obj in selection do
						(
							if classOf obj[1].track != bezier_float do obj.visibility = bezier_float()
							fn_AddVisKey obj 0.0
						)
					)
				)
			) -- End on btn_VisOff
			
			-----------------------------------------------------------------------------
			-- Visibility ON
			----------------------------------------------------------------------------- 
			
			on btn_VisOn pressed do
			(
				if selection.count >= 1 then
				(
					undo on
					(
						for obj in selection do
						(
							if classOf obj[1].track != bezier_float do obj.visibility = bezier_float()
							fn_AddVisKey obj 1.0
						)
					)
				)
			) -- End on btn_VisOn
			
			-----------------------------------------------------------------------------
			-- Delete Visibility Key On Selected Object
			----------------------------------------------------------------------------- 
			on btn_DelVisKey pressed do 
			(	
				for i in selection do 
				(		
					deletekeys i.visibility.controller
				)
			) --  End on btn_DelVisKey
			
		) -- End Rollout
		
		createDialog roll_VisibilityDialog 200 180
		
	) -- End Script

azardei · 2011-09-15

Thx, I am looking for something simple with animate on that I can add to may program. I tryed this
for o in geometry do
(o.visibility = bezier_float()
with animate on
(
at time 0 o.visibility.controller.value = [0,0,0]
at time 100 o.visibility.controller.value = [0,1,1]
)
)
but I get

-- Error occurred in o loop; filename: C:\Users\Avner Dei\Documents\3dsMax\Scripts\viz.ms; position: 138; line: 6
-- Frame:
-- o: $Box001
-- Unable to convert: [0,0,0] to type: Float