Highlighted

Scripting - Keyframes not moving properly.

Community Beginner ,
Mar 17, 2020

Copy link to clipboard

Copied

I am trying to move the selected keyframes of the selected properties with script, but it is moving only first selected property keyframes and not second ones.
Here is my script -
var mComp = app.project.activeItem;
var selecLayers = mComp.selectedLayers;
for (i=0;i<selecLayers.length; i++){
var seleProp = selecLayers[i].selectedProperties;
for (j=0; j< seleProp.length; j++){
var seleKeys = seleProp[j].selectedKeys;
for (k=seleKeys.length - 1;k>=0; k--){
var newKeyValue = seleProp[j].keyValue(seleKeys[k]);
var newKeyTime = seleProp[j].keyTime(seleKeys[k]) + 0.06;
var newKey = seleProp[j].addKey(newKeyTime);
seleProp[j].setValueAtKey(newKey, newKeyValue);
seleProp[j].removeKey(seleKeys[k]);
}
}
}
what Am i doing wrong here?

Topics

Scripting

Views

49

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Scripting - Keyframes not moving properly.

Community Beginner ,
Mar 17, 2020

Copy link to clipboard

Copied

I am trying to move the selected keyframes of the selected properties with script, but it is moving only first selected property keyframes and not second ones.
Here is my script -
var mComp = app.project.activeItem;
var selecLayers = mComp.selectedLayers;
for (i=0;i<selecLayers.length; i++){
var seleProp = selecLayers[i].selectedProperties;
for (j=0; j< seleProp.length; j++){
var seleKeys = seleProp[j].selectedKeys;
for (k=seleKeys.length - 1;k>=0; k--){
var newKeyValue = seleProp[j].keyValue(seleKeys[k]);
var newKeyTime = seleProp[j].keyTime(seleKeys[k]) + 0.06;
var newKey = seleProp[j].addKey(newKeyTime);
seleProp[j].setValueAtKey(newKey, newKeyValue);
seleProp[j].removeKey(seleKeys[k]);
}
}
}
what Am i doing wrong here?

Topics

Scripting

Views

50

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Most Valuable Participant ,
Mar 17, 2020

Copy link to clipboard

Copied

On first glance I can't see an issue, but the pertinent question might be whether there are actually invisible or inactive contextual properties somewhere that may break the selection logic. Same for props with no keys at all.

 

Mylenium

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Community Beginner ,
Mar 17, 2020

Copy link to clipboard

Copied

yes it is breaking for example - if i select 2 keys from position and 2 keys from opacity and apply this script, it will move position keys but wont move opacity keys. it is breaking at second round.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...