My problem is basic.
I have write à script who add a keyframe on position property at the current time.
But i have an expression running on position property and it add only the originla value and not the expression value.
Here is the code expression.
I know that i can translate expression into keyframes but it create too much keyframes (the expression create a still value).
So i can write in script to translate expression into keyframes and delete all keyframes except the current time keyframes. But how to convert expression in keyframes with script.
Maybe with AppCommand but which code (i have find CS3 appcommand code here, but i don't know if there is changes with CS4).
Edit : i have find the AppfindCommand command who could be a good way.
If anybody have a better solution.
Thanks.
Add keyframe with expression value
Moderator: Paul Tuersley
-
- Posts: 704
- Joined: June 5th, 2004, 7:59 am
- Location: London, UK
I'm not entirely sure what you're trying to do. But couldn't you just get the script to read the resulting value from the expression, then make it delete the expression and set the property to the value you just read?
This is my script code.
I don't know the instruction for take the expression value, because when i use .value(curTime) it takes the static value and not the real value calculate by the expression.
So if it doesn't work i will use an other logic, maybe only use script for calculate the position.
Thanks for the help.
Code: Select all
{
var myProj = app.project;
var myComp = myProj.activeItem;
var mySelectedLayers = myComp.selectedLayers;
app.beginUndoGroup("Function");
for (var i = 0; i < mySelectedLayers.length; i++) {
var curLayer = mySelectedLayers[i];
var curTime = app.project.activeItem.time;
var oldValue = curLayer.position.value(curTime);
curLayer.position.setValueAtTime(curTime,oldValue);
}
app.endUndoGroup();
}
So if it doesn't work i will use an other logic, maybe only use script for calculate the position.
Thanks for the help.
-
- Posts: 704
- Joined: June 5th, 2004, 7:59 am
- Location: London, UK
I think you want property.valueAtTime(curTime, false);
The second argument is whether you take the preExpression value. See the valueAtTime() method in the AE CS3 scripting guide.
The second argument is whether you take the preExpression value. See the valueAtTime() method in the AE CS3 scripting guide.