Copy link to clipboard
Copied
Hello,
I'm a beginner in developing extensions for Premiere Pro, and I have a few questions while writing .jsx scripts:
Is there a way to create an undo group in Premiere Pro extensions, similar to After Effects scripts?
For example, like this in AE:
app.beginUndoGroup("tttest"); app.endUndoGroup();
Is it possible to modify the text content created using the Text Tool (Essential Graphics) via the extension?
I tried to set the in and out points of a graphic clip in the sequence to a specific range — for example, from frame 24 to frame 48.
However, setting .clip.start doesn't seem to work correctly. Could you provide a working code example for how to reposition and trim a graphic clip in the timeline?
Here is a portion of the .jsx code related to my third question.
function but3onClick() {
var sequence = app.project.activeSequence;
if (!sequence) { app.setSDKEventMessage("没有活动序列", "warning"); return; }
var selectedClips = getSelectedClips(); // 获取选中的剪辑
if (!selectedClips) return;
if (selectedClips.length > 1) { app.setSDKEventMessage("请只选择单个剪辑", "warning"); return; }
var selectedClip = selectedClips[0].clip; // 获取选中的剪辑对象
var track = sequence.videoTracks[selectedClips[0].trackIndex]; // 获取选中剪辑所在的轨道
var ticksPerFrame = sequence.timebase; // 获取时间基准(每帧的ticks数)
for (var i = track.clips.length - 1; i >= 0; i--) { // 遍历轨道上的所有剪辑
var clip = track.clips[i];
if (clip.start.ticks == selectedClip.start.ticks && clip.end.ticks == selectedClip.end.ticks)
continue;
track.clips[i].remove(0, 0);
}
selectedClip.start = new Time();
selectedClip.start.ticks = 24 * ticksPerFrame;
}
//获取选中的剪辑
function getSelectedClips() {
var sequence = app.project.activeSequence;
if (!sequence) { return; }
var selectedClips = [];
for (var i = 0; i < sequence.videoTracks.length; i++) {
var track = sequence.videoTracks[i];
for (var j = 0; j < track.clips.length; j++) {
var clip = track.clips[j];
if (clip.isSelected())
selectedClips.push({
clip: clip,
trackIndex: i,
});
}
}
if (!selectedClips || selectedClips.length == 0) { // 如果没有选中剪辑
app.setSDKEventMessage("当前没有选中任何剪辑", "warning"); return;
}
var baseTrackIndex = selectedClips[0].trackIndex; // 获取第一个选中剪辑的轨道索引
for (var i = 1; i < selectedClips.length; i++)
if (selectedClips[i].trackIndex != baseTrackIndex) {
app.setSDKEventMessage("选中的剪辑不在同一轨道上", "warning");
return;
}
return selectedClips;
}
> Is there a way to create an undo group in Premiere Pro extensions, similar to After Effects scripts?
Not in ExtendScript; UXP plugins (supported in PPro beta builds) do support undo groups.
>Is it possible to modify the text content created using the Text Tool (Essential Graphics) via the extension?
No; the ExtendScript APIs work on the editable parameters exposed by .mogrts created in After Effects.
Here's PProPanel moving trackItems.
Here's some example code that removes 3 seconds from the end of a trackItem.
var seq = app.project.activeSequence;
if (seq) {
var firstVidItem = seq.videoTracks[0].clips[0];
if (firstVidItem){
var oldEnd = firstVidItem.end;
var newEnd = oldEnd;
newEnd.seconds = newEnd.seconds - 3;
firstVidItem.end = newEnd;
}
}
Copy link to clipboard
Copied
> Is there a way to create an undo group in Premiere Pro extensions, similar to After Effects scripts?
Not in ExtendScript; UXP plugins (supported in PPro beta builds) do support undo groups.
>Is it possible to modify the text content created using the Text Tool (Essential Graphics) via the extension?
No; the ExtendScript APIs work on the editable parameters exposed by .mogrts created in After Effects.
Here's PProPanel moving trackItems.
Copy link to clipboard
Copied
Thank you very much.
By the way, besides using .move(), is there a way to set the duration or end time of a graphic clip?
Copy link to clipboard
Copied
Here's some example code that removes 3 seconds from the end of a trackItem.
var seq = app.project.activeSequence;
if (seq) {
var firstVidItem = seq.videoTracks[0].clips[0];
if (firstVidItem){
var oldEnd = firstVidItem.end;
var newEnd = oldEnd;
newEnd.seconds = newEnd.seconds - 3;
firstVidItem.end = newEnd;
}
}
Copy link to clipboard
Copied
Thank you,
but I have another question. Why is it that .ticks cannot be set, and only .seconds can be set?
var newStart = selectedClip.start;
// newStart.ticks =254016000000
newStart.seconds = 1;
selectedClip.start = newStart;
Copy link to clipboard
Copied
>Why is it...
Sorry, we can't provide a specific motivation for that decision.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now