Skip to content

Instantly share code, notes, and snippets.

@GoodBoyNinja
Created June 7, 2021 20:53
Show Gist options
  • Save GoodBoyNinja/7c2156e13cce1f25c34f04f3263f1fc1 to your computer and use it in GitHub Desktop.
Save GoodBoyNinja/7c2156e13cce1f25c34f04f3263f1fc1 to your computer and use it in GitHub Desktop.
pass a layer to freeze it where the time indicator currently is. Pass a specific time (in seconds) to freeze somewhere else.
function freezeLayerAtCurrentTime(layer, specificTime) {
if (!layer) {
// no layer
return false
};
try{
layer.timeRemapEnabled = true;
var timeRemapProp = layer("ADBE Time Remapping");
var container = layer.containingComp || null;
if (!container) {
//container comp not found
return false
}
var time = (specificTime && !isNaN(specificTime)) ? specificTime : container.time;
timeRemapProp.setValueAtTime(time ,timeRemapProp.valueAtTime(time, false) );
// remove first and last keys
var keysAmount = timeRemapProp.numKeys;
if (keysAmount == 3) {
timeRemapProp.removeKey(3);
timeRemapProp.removeKey(1);
// Freeze Seems Successful
return true;
};
}catch(e){
// something went wrong, you could print or alert the error
}
return false
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment