[Closed] Copying keys between Controllers
Heya
I have an issue where when I update a cat rig it confuses the data that’s stored in the tracks for a set of custom attributes it has on it. To get round this I’m writing a piece of code which will just store the original keys for the custom attribute subanims before the rig is updated and then reapply them. I have not found a way to make a deep copy of the keys though as when I clone them and then try to reapply the originals are deleted, the original keys are also lost.
I’ve now attempted to copy the controllers and then copy the keys back to the original controllers but I’m only getting the keys come through for a single subanim. Can anyone explain where I’m going wrong please?
fn CopyKeysBetweenControllers &OGController &newController =
(
for i = 1 to newController[1].numSubs do
(
newController[1].SelectedLayer = i
format "Pasting keys on SubAnim: % \n" newController[1][i].name
with animate on
(
for key in OGController[1].controller.LayerControllers[i].keys do
(
format "Pasting Key: % \n" key
at time key.time newController[1].controller.LayerControllers[i] = key.value
)
)
format "Resulting Keys: % \n" newController[1].controller.LayerControllers[i].keys
)
)
deletekeys newcontroller
for k in oldcontroler.keys do appendkey newcontroller.keys k
Hi DenisT
Thanks very much, I’d tried various combos of copying key tracks and trying to reapply them etc. But your approach of copying the controllers and then appending the keys back seems to be the way to go. I’ve been able to complete what I was doing now.
Cheers I appreciate the help.
I think it can be easier to copy whole controller if you need to copy all keys. Just take this option in the mind.
delete objects
b = box()
seed 0
with animate on for t in #(0, 20, 37, 49) do at time t b.width = (random 10 50)
b.length.controller = copy b.width.controller
b.height.controller = copy b.width.controller