LearnedOne
04-06-2007, 08:18 PM
For this project I’m working on, I am trying to use the new animation layers in Max9 to create a customizable animation sequence. I have created several short animations on multiple layers, one per layer, and then am using Maxscript to create a new layer which will hold a specified sequence of those short animations. The code essentially creates a temporary layer, copies a layer with one of the previously created short animations and pastes it onto the temporary layer, then moves the keys on the temporary layer forward so the animations do not overlap, and finally collapses the temporary layer onto the main sequence layer.
Now, my problem arises in moving the keys forward on the temporary layer. For testing purposes, I have created a basic scene with one box in it. The box has a couple layers with animation; LayerA moves the box back and forth once on the x axis, LayerB moves the box back and forth once on the y axis.
Initially I tried setting the Temporary layer as the active layer and then executing insertTime $Box 0f 10fHowever, although this worked, it shifted the keys in all layers forward 10 frames. I need it to only shift the keys in the temporary layer. So then I discovered I could specify the layer to be effected under each controller. The following worked perfectly, shifting only the keys under the temporary layer.insertTime $Box.pos.controller.Temp 0f 10f
Now, this is great for my little test sequence. However, I plan on actually using this with fully animated characters. These characters will have keys in more than just the position controller. Here is where the problem comes in. I found the following function online which allows me to collect all the keyable controllers for a specific object. I then added the layer name to the end of each resulting controller and tried to shift the keys for that controller in the temp layer.fn getControllers ref =
(
local ctrlList = #()
local refList = refs.dependsOn ref
for r in refList do
(
if (isProperty r #keyable == true) then
(
append ctrlList r
)
join ctrlList (getControllers r)
)
return ctrlList
)
nodesControllers = getControllers $Box
for c in nodesControllers do
(
pathname = exprForMaxObject c
cpaths = execute (pathname + “.” + “Temp”)
insertTime cpaths 0f 10f
)
This function works well and returns an array of all the keyable controllers for the object. However, I am getting errors and unexpected results when I try to add the temp layer to the controller. For example:cpaths = $Box.scale.controller.Temp
[1,1,1]
$Box.transform.controller.Temp
-- Unknown property: “Temp” in Controller:Position_Rotation_Scale
I believe part of the problem is that more controllers are being returned than are actually used. As this was tested using my simple box animation, the only controller keyed is the position controller, yet the scale and transform controller were returned.
Either way, if anyone has any idea what I’m doing wrong or a better way to move all the keys on a specific animation layer, please let me know. Thank you in advance.
Now, my problem arises in moving the keys forward on the temporary layer. For testing purposes, I have created a basic scene with one box in it. The box has a couple layers with animation; LayerA moves the box back and forth once on the x axis, LayerB moves the box back and forth once on the y axis.
Initially I tried setting the Temporary layer as the active layer and then executing insertTime $Box 0f 10fHowever, although this worked, it shifted the keys in all layers forward 10 frames. I need it to only shift the keys in the temporary layer. So then I discovered I could specify the layer to be effected under each controller. The following worked perfectly, shifting only the keys under the temporary layer.insertTime $Box.pos.controller.Temp 0f 10f
Now, this is great for my little test sequence. However, I plan on actually using this with fully animated characters. These characters will have keys in more than just the position controller. Here is where the problem comes in. I found the following function online which allows me to collect all the keyable controllers for a specific object. I then added the layer name to the end of each resulting controller and tried to shift the keys for that controller in the temp layer.fn getControllers ref =
(
local ctrlList = #()
local refList = refs.dependsOn ref
for r in refList do
(
if (isProperty r #keyable == true) then
(
append ctrlList r
)
join ctrlList (getControllers r)
)
return ctrlList
)
nodesControllers = getControllers $Box
for c in nodesControllers do
(
pathname = exprForMaxObject c
cpaths = execute (pathname + “.” + “Temp”)
insertTime cpaths 0f 10f
)
This function works well and returns an array of all the keyable controllers for the object. However, I am getting errors and unexpected results when I try to add the temp layer to the controller. For example:cpaths = $Box.scale.controller.Temp
[1,1,1]
$Box.transform.controller.Temp
-- Unknown property: “Temp” in Controller:Position_Rotation_Scale
I believe part of the problem is that more controllers are being returned than are actually used. As this was tested using my simple box animation, the only controller keyed is the position controller, yet the scale and transform controller were returned.
Either way, if anyone has any idea what I’m doing wrong or a better way to move all the keys on a specific animation layer, please let me know. Thank you in advance.
