Copy link to clipboard
Copied
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();
Copy link to clipboard
Copied
I have a script that sets work area start to playhead, but it doesn't set work area start to playhead when playhead is one frame before work area end.
(there are some mistakes in the main post, and i don't know if you can edit the posts)
Thank you
Copy link to clipboard
Copied
I thik it's the same issue as your previous post. Try replacing this:
comp.workAreaStart = playheadPosition;
comp.workAreaDuration = currentWorkAreaEnd - playheadPosition;
with this:
comp.workAreaStart = 0;
comp.workAreaDuration = comp.duration;
comp.workAreaStart = playheadPosition;
comp.workAreaDuration = currentWorkAreaEnd - playheadPosition;
Copy link to clipboard
Copied
I did set that at line 12 and 13, but it just doesn't work for some reason.
Copy link to clipboard
Copied
It seems to work for me, but I may not be testing it in the same way.
<edit>
Also, I put those lines at line 30.
Copy link to clipboard
Copied
Actually, just ignore everything I suggested. You code works fine for me, but I must not be testing the way you are.
Copy link to clipboard
Copied
It works with a different approach.
Copy link to clipboard
Copied
also the issues happens when my frame rate is, 23.976, its just unable to set the work area duration correctly, but with 24 frames it works properly
Copy link to clipboard
Copied
I'll try that.