Skip to main content
scottl50240317
Participant
March 10, 2020
Answered

Cannot assign values to trackItem.start or end

  • March 10, 2020
  • 3 replies
  • 5975 views

How do you change the value of "trackItem.end"? It worked before; now it doesn't.

 

var seq = app.project.activeSequence;
var vClip = seq.videoTracks[0].clips[0];
var aClip = seq.audioTracks[0].clips[0];

 

// Method 1: No error, but the value assignment doesn't work. No changes are made.

vClip.end.seconds = aClip.end.seconds; 

 

// Method 2: Error. Cannot set property end. Changes are made, but the program quits on me after that.

vClip.end = aClip.end.seconds;

 

My script worked with Method 2 above a few months ago. Now it doesn't. Maybe there have been some changes to Premiere Pro or ExtendScript?

This topic has been closed for replies.
Correct answer Bruce Bullis

> Sorry, this code does work (moves a clip from before 120 seconds to end at 120 seconds).


Not here, on multiple machines. Not sure what the difference between our configurations is.

 

Should this work in 14.x?

 

Again, if it worked in 13.x, it should work in 14.x.


Update: Andrew was on to something. In PPro 14.x, the change works, but returns a scripting error. We're tracking the issue as DVAPR-4224243: "Changing the start and end time of a trackItem returns an error (but seems to work)" We'll keep you informed of our progress.

3 replies

guntramp26642460
Inspiring
April 9, 2021

How is progress going on? 🙂

It still seems to occur in PPro 14.9.

 

Cheerz,

guntram

guntramp26642460
Inspiring
April 9, 2021

...on windows10

Inspiring
April 10, 2021

There are some troubles with both classes TrackItem and classes QETrackItems. For example, in QE it's impossible to paint trackitems - AP crush immediately :-)Try to use unofficial QE classes and methods for your task. Sorry, Bruce! 🙂

jondrometa
Inspiring
September 21, 2020

Any updates on this issue for assigning trackItem.start or .end in 14.x? 

 

This is the only way it's worked for me:

 

var newStart = new Time();
newStart.seconds = 20;

var newEndTime = new Time();
newEndTime.seconds = 40;

app.project.activeSequence.videoTracks[2].clips[0].start = startTime;//moves clip to 20 seconds, but throws error and does not move forward.

app.project.activeSequence.videoTracks[2].clips[0].end = newEndTime;//never makes it this far.

 

 
The code works... moving the clip to the 20 second mark. But VS Code throws an error every time and gets stuck there. 
 
Any tips on how to tell Extendscript to ignore the error for now? Or maybe an approach through the QE DOM?
Bruce Bullis
Legend
September 21, 2020

I'm pretty sure we'll need to change/fix something, to get rid of that error you're seeing in VSCode. 

jondrometa
Inspiring
September 21, 2020

Agreed.
In the meantime, I just wrote a try/catch function to hide the error while debugging. Hope it helps everyone out... 

 

 

//Helper function to hide the error while debugging in VS Code. Pass "start" or "end" as a string accordingly:
function changeStartOrEndTimes(trackItem, change, time){
    try {
        if (change == "start"){
     //code that causes the error:
            trackItem.start = time.seconds;

        } else if (change == "end"){
            trackItem.end = time.seconds;
        }
  
    } catch (e) {
    //catch the error and leave us alone:
        jsonWriteLn("there was an error, but we're ignoring it... " + e);
    }
}

//sample use:
newStartTime = new Time();
newStartTime.seconds = 20;
changeStartOrEndTimes(app.project.activeSequence.videoTracks[2].clips[0], "start", newStartTime);

newEndTime = new Time();
newEndTime.seconds = 40;
changeStartOrEndTimes(app.project.activeSequence.videoTracks[2].clips[0], "end", newEndTime);

 

Bruce Bullis
Legend
March 10, 2020

In what version of PPro did the call previously work?

I don't see why method 2 would ever work; you're attempting to assign 'seconds' to a Time, which has a 'seconds' member...

scottl50240317
Participant
March 10, 2020

The PPro version was 13.x. I actually had some difficulty understanding why Method 1 worked and why "seconds" to a seconds member didn't, but I figured that's simply the way it was. Anyhow, now my scripts that use Mehotd 1 type of lines don't work. (Well, actually, a change is made once, and the program quits, which is quite weird.) Method2, as I mentioned, doesn't give an error message, but no changes are made. Maybe I should try reinstalling PPro? 

 

So... I went ahead and installed 13.1.5 and reinstalled 14.0.3, and the results have not changed.

 

Method 1 doesn't do a thing with either 13.1.5 or 14.0.3. After executing the code, the values do not change.

Method 2 works flawless with 13.1.5. The track item is assigned a new value, and this is reflected in the timeline, with no errors. 14.0.3 does give an error, but it does assign the new value before it quits execution of the code.

 

Now... I've disabled the new world feature in PPro 14, and Method 2 starts working again...

Bruce Bullis
Legend
March 11, 2020

> Now... I've disabled the new world feature in PPro 14, and Method 2 starts working again...

Yes, Old World's charitable type coercion ("What's this thing? I'll just pretend it's a String") is gone, and won't be coming back.