Question
Work Area start doesn't set when the playhead is one frame before work area end.
I have a script that sets work area start to playhead, but if doesnt set work area start to playhead when playhead it one frame before work area end.
Thank you 🙏
app.beginUndoGroup("Set Work Area to selected layers");
{
// Get the current active composition
var comp = app.project.activeItem;
if (comp instanceof CompItem) {
// Save the current work area start and end
var currentWorkAreaStart = comp.workAreaStart;
var currentWorkAreaEnd = comp.workAreaStart + comp.workAreaDuration;
// Set the work area start and end to the composition start and full duration
comp.workAreaStart = 0;
comp.workAreaDuration = comp.duration;
// Get the current playhead time (time indicator)
var playheadPosition = comp.time;
if (playheadPosition >= currentWorkAreaEnd) {
// If the playhead is after or at the current work area end
var newWorkAreaStart = playheadPosition;
var workAreaLength = currentWorkAreaEnd - currentWorkAreaStart;
// Set the new work area start to the playhead position
comp.workAreaStart = newWorkAreaStart;
// Set the work area end based on the previous work area length
comp.workAreaDuration = workAreaLength;
} else {
// Otherwise, set the work area start to the playhead position and the end to the previous work area end
comp.workAreaStart = playheadPosition;
comp.workAreaDuration = currentWorkAreaEnd - playheadPosition;
}
} else {
}
}
app.endUndoGroup();
