PDA

View Full Version : TCB Script giving error pls help


m3dhunk
04-22-2009, 02:27 AM
I downloaded a script which makes the tension(TCB) value 50 for all the selected cubes in all the keyframes. But its giving error in this line(Underlined).

--Work for all cubes in selection
for cube in selection do (
--Change 6 to number of keyframes
for i = 1 to 6 do (
cube.rotation.controller.keys[i].tension = 50
)
)

Can anyone pls help.
I am using 3dsmax 9. Early response would helpful.

m3dhunk

LoneRobot
04-22-2009, 09:13 AM
Its probably because the item you are changing has less than 6 keys.

hardcoding a value like this into a loop that uses a changeable array like selection is never a great idea, as you dont know how many keys the object might have (in theory)

its much better to retrieve the key array and loop through that, unless you know it's its the first 6 keys you want to change.

for cube in selection do
(
-- store the array of keys
local KeyArray = cube.rotation.controller.keys
-- check there is a TCB rotation controller
if classof cube.rotation.controller == tcb_rotation then
-- iterate the keyarray and change the values
for i = 1 to KeyArray.count do KeyArray[i].tension = 50
)

m3dhunk
04-23-2009, 04:16 AM
Its working!!!:bounce:

Thankyou so much, you have made my day.

m3dhunk

CGTalk Moderation
04-23-2009, 04:16 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.