Hi all,
first sorry for all the questions. Your help is helping me alot in learning this stuff. I though it would be better to post in different threads so that other people easily can find the answer as well by doing a simple Google search.
Anyway, I have a variable called "myCamera" (for example). This layer has keyframes on each frame. I want to remove all keyframes (position, rotation, point of intrest) and reset the transform value. Normally I would click the stopwatch to remove all keyframes, and then I would click the reset button. I searched both the scripting guide and this site, but the only thing I could find was really old and pretty much said it couldn't be done.
best regards,
Simon.
Reset value and remove keyframes - possible?
Moderator: Paul Tuersley
- lloydalvarez
- Enhancement master
- Posts: 460
- Joined: June 17th, 2004, 9:27 am
- Location: New York City, NY
- Contact:
You will need to setup for loops to remove the keyames one by one on each property that has them. When you remove keyframes you probably want to do it in reverse because the numKeyframes value will change when you remove a keyframe and will affect your loop. The CS3 guide is still relevant, very little info in there is wrong or no longer applicable. Where did it say this was not possible?
Lloyd
Lloyd
Thank you for your respond Lloyd. I couldn't find anything about removing (exept for remove one keyframe) in the scripting guide. So then I searched here and all I could find was old responses that seemed very complicated. Thought it would be a pretty basic thing. Will have to dig deeper into that. But what about reseting transform values? That I haven't found anything about anywhere.
- lloydalvarez
- Enhancement master
- Posts: 460
- Joined: June 17th, 2004, 9:27 am
- Location: New York City, NY
- Contact:
Like I said earlier you will need to create a loop and remove the keyframes one by one so the info you find on how to remove one keyframe is what you'll want to use. Not sure there is a way to reset the transforms to their defaults but you can probably calculate them easily. I believe anchor and position is always half the width and half the height, then scale and opacity are 100 and rotation is 0.
-Lloyd
-Lloyd
Got it working, here's the code in case anyone needs it in the future:
Thank you for your help.
Code: Select all
var myComp = app.project.activeItem;
var myLayer = myComp.layer(1);
var numberKeys = myLayer.rotation.numKeys;
for (var i=numberKeys; i>0; i --) {
myLayer.rotation.removeKey(i);