Activity › Forums › Adobe After Effects Expressions › Delete layer marker with specific comment
-
Delete layer marker with specific comment
Posted by Kevin Snyder on October 10, 2022 at 4:07 pmI’ve been looking through the AE scripting guide, and I’ve been able to write a script to add a layer marker with a comment, but how can I delete the same layer marker with the comment? I can’t seem to find the answer.
Kevin Snyder replied 2 years, 3 months ago 2 Members · 6 Replies -
6 Replies
-
Dan Ebberts
October 10, 2022 at 6:43 pmI was surprised to find that removeKey() doesn’t accept markerComment as an index, so I guess you have to do it the brute force way:
var myProp = app.project.activeItem.layer(1).property("Marker");
for (var i = 1; i <= myProp.numKeys; i++){
if (myProp.keyValue(i).comment == "test"){
myProp.removeKey(i);
break;
}
} -
Kevin Snyder
October 10, 2022 at 7:26 pmThanks, Dan. I gave it a go and it doesn’t remove the key. I’m not getting an error message either.
-
Dan Ebberts
October 10, 2022 at 7:35 pmIt worked for me. It wouldn’t give an error if it didn’t find a marker with your comment (you did change that from “test”, yes?)
-
Kevin Snyder
October 10, 2022 at 7:59 pmOkay, it’s working. I just changed it to run on the selected layer. Thank you.
-
Dan Ebberts
October 10, 2022 at 8:17 pmThis is probably better:
var myProp = app.project.activeItem.layer(1).property("Marker");
try{
var t = myProp.keyTime("test");
var myKey = myProp.nearestKeyIndex(t);
myProp.removeKey(myKey);
}catch(e){
}
Reply to this Discussion! Login or Sign Up