ScriptSpot

Forum topic · General Scripting

intangent outtangent error

By izztti · 2010-11-27

Description

have an error while creatin a key on 0frame and while there is no another key.
otherwise it runs well if there is minimum one key while you are on frame 0 or you are creatin the first speed key.


(
	global zztTool
	rollout zzTool "super spray"
	(
		
		group"Set Speed" --across: 2
		(
			spinner spSpeed "Speed" range:[0,1000,30]-- animatable

			button btn_deleteKeys "Delete All Existing Keys" width:120 height:20 setColor:red
		)
		/*
		group
		(
		)*/
		on btn_deleteKeys pressed do
		(
			(
				getST=slidertime
			sliderTime = 0f
			obj = getCurrentSelection ()
			deleteKeys obj #allKeys
				sliderTime = getST
			)
		)
				on spSpeed changed val do
		(
			for obj in (selection as array) do
			if classof obj == superspray then
			(
				s=slidertime
				hiz=spSpeed.value
				at time s animate on
				obj.speed = (hiz/2.54)
				a = getKeyIndex obj.speed.controller s
				obj.speed.controller.keys[a].inTangentType = #linear
				obj.speed.controller.keys[a].outTangentType = #fast
				
			)
		)
	
	)
	try
	(
		closeRolloutFloater zztTool
	)	catch ()
	zztTool=newRolloutFloater "fountain floater" 300 100
	addRollout zzTool zztTool
)
Comments (3)

izztti · 2010-11-28

thanks. that works :)

Anubis · 2010-11-28

yep, array index in mxs start from 1,
so check if there are keys (a > 0):

a = getKeyIndex obj.speed.controller s
if a > 0 do (
    obj.speed.controller.keys[a].inTangentType = #linear
    obj.speed.controller.keys[a].outTangentType = #fast
)

need help about "inTangentType"

izztti · 2010-11-27

on a frame that is not "0f" it works well
on frame which is not "0f" it works well
but on frame "0f" and if there isn't another animation key,
it gives an error.
can anyone help me about the error.


---------------------------------------------------
---------------------------------------------------
(
	global zztTool
	rollout zzTool "super spray"
	(
		
		group"Set Speed" --across: 2
		(
			spinner spSpeed "Speed" range:[0,1000,30]-- animatable

			button btn_deleteKeys "Delete All Existing Keys" width:120 height:20 setColor:red
		)
		/*
		group
		(
		)*/
		on btn_deleteKeys pressed do
		(
			(
				getST=slidertime
			sliderTime = 0f
			obj = getCurrentSelection ()
			deleteKeys obj #allKeys
				sliderTime = getST
			)
		)
				on spSpeed changed val do
		(
			for obj in (selection as array) do
			if classof obj == superspray then
			(
				s=slidertime
				hiz=spSpeed.value
				at time s animate on
				obj.speed = (hiz/2.54)
				a = getKeyIndex obj.speed.controller s
				obj.speed.controller.keys[a].inTangentType = #linear
				obj.speed.controller.keys[a].outTangentType = #fast
				
			)
		)
	
	)
	try
	(
		closeRolloutFloater zztTool
	)	catch ()
	zztTool=newRolloutFloater "fountain floater" 300 100
	addRollout zzTool zztTool
)
Attachments