Highlighted

Cannot assign values to trackItem.start or end

Community Beginner ,
Mar 09, 2020

Copy link to clipboard

Copied

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?

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.
TOPICS
SDK

Views

719

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Cannot assign values to trackItem.start or end

Community Beginner ,
Mar 09, 2020

Copy link to clipboard

Copied

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?

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.
TOPICS
SDK

Views

720

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Mar 09, 2020 1
Adobe Employee ,
Mar 10, 2020

Copy link to clipboard

Copied

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...

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Mar 10, 2020 0
Community Beginner ,
Mar 10, 2020

Copy link to clipboard

Copied

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...

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Mar 10, 2020 0
Adobe Employee ,
Mar 11, 2020

Copy link to clipboard

Copied

> 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. 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Mar 11, 2020 0
Community Beginner ,
Mar 11, 2020

Copy link to clipboard

Copied

Thanks, but the question for me, then, is how is that lines like "vClip.end.seconds = aClip.end.seconds;" do not work. Something like "[trackItem].end.seconds = 10" doesn't work, either. The following may illustrate the predicament I am in:

 

var seq = app.project.activeSequence;
var vClip = seq.videoTracks[0].clips[0]; // end: 32
var aClip = seq.audioTracks[0].clips[0]; //  end: 22

$.writeln(vClip.end.seconds); // prints 32
vClip.end.seconds = vClip.end.seconds - 5;
$.writeln(vClip.end.seconds); // still prints 32
vClip.end.seconds = aClip.end.seconds;
$.writeln(vClip.end.seconds); // still prints 32

 

Both versions of PPro give the same results. Am I doing something wrong here?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Mar 11, 2020 0
Adobe Employee ,
Mar 11, 2020

Copy link to clipboard

Copied

Can I have a .prproj, an ExtendScript snippet, and step-by-step instructions on how to reproduce the behavior you've described, above? mailto:bbb@adobe.com

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Mar 11, 2020 0
Community Beginner ,
May 29, 2020

Copy link to clipboard

Copied

Was this resolved? I'm having the same issue. The below code works in PP 13.1.5 but not in PP 14.2.0. In PP 14.2.0 I get an error at myClip.end = endTime saying cannot set property end.

 

var desiredEnd = 120;
var myClip = app.project.activeSequence.videoTracks[0].clips[0];
var endTime = myClip.end;
endTime.seconds = desiredEnd;
var startTime = myClip.start;
startTime.seconds = endTime.seconds - myClip.duration.seconds;           
myClip.end = endTime;
myClip.start = startTime; 

 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
May 29, 2020 0
Adobe Employee ,
May 29, 2020

Copy link to clipboard

Copied

I think the difficulty is this: While you can change the values within the myClip.end Time object, you cannot replace that actual Time object with a different one. 

This works here, in 14.2 (though the math gets weird, with clips <120 seconds long):

 

var desiredEnd = 120;
var myClip = app.project.activeSequence.videoTracks[0].clips[0];
var endTime = myClip.end;
endTime.seconds = desiredEnd;
var startTime = myClip.start;
startTime.seconds = endTime.seconds - myClip.duration.seconds;
myClip.end.ticks = endTime.ticks;
myClip.start.ticks = startTime.ticks;

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
May 29, 2020 0
Community Beginner ,
May 29, 2020

Copy link to clipboard

Copied

I tried this and while it doesn't produce an error like trying to replace the Time object it doesn't seem to move the clip on the timeline to the desired end. Am I doing something wrong? Is it possible to move a clip around the timeline like this in 14.2 like you could in 13.1.5?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
May 29, 2020 0
Community Beginner ,
Jun 01, 2020

Copy link to clipboard

Copied

Is it possible to move a clip around the timeline in 14.2 like you could in 13.1.5?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jun 01, 2020 0
Adobe Employee ,
Jun 01, 2020

Copy link to clipboard

Copied

Whatever was possible in 13.x, remains possible in 14.x.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jun 01, 2020 0
Community Beginner ,
Jun 01, 2020

Copy link to clipboard

Copied

Ok. Is it possible using the same methods or have methods been been changed between versions? Should the below method move the clip from say 10 seconds to 115 seconds (assuming 5 second duration) in 14.x? It doesn't seem to my end. If not, is there another method to move a clip around the timeline in 14.x? If so, what is that method? At this stage I've resorted to placing a clip on the timeline to get the duration, deleting the clip, then re-placing the clip based on the stored duration and desired end which is hardly ideal.

var desiredEnd = 120;
var myClip = app.project.activeSequence.videoTracks[0].clips[0];
var endTime = myClip.end;
endTime.seconds = desiredEnd;
var startTime = myClip.start;
startTime.seconds = endTime.seconds - myClip.duration.seconds;
myClip.end.ticks = endTime.ticks;
myClip.start.ticks = startTime.ticks;

 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jun 01, 2020 0
Adobe Employee ,
Jun 02, 2020

Copy link to clipboard

Copied

Your code doesn't move a clip, in 13.1.5 or 14.2.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jun 02, 2020 0
Community Beginner ,
Jun 02, 2020

Copy link to clipboard

Copied

var desiredEnd = 120;
var myClip = app.project.activeSequence.videoTracks[0].clips[0];
var endTime = myClip.end;
endTime.seconds = desiredEnd;
var startTime = myClip.start;
startTime.seconds = endTime.seconds - myClip.duration.seconds;           
myClip.end = endTime;
myClip.start = startTime; 

Sorry, this code does work (moves a clip from before 120 seconds to end at 120 seconds). Should this work in 14.x? If not, is there another method to move a clip around the timeline in 14.x? If so, what is that method?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jun 02, 2020 0
Adobe Employee ,
Jun 02, 2020

Copy link to clipboard

Copied

> 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.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jun 02, 2020 0
Adobe Employee ,
Jun 03, 2020

Copy link to clipboard

Copied

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.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jun 03, 2020 0
Community Beginner ,
Jun 09, 2020

Copy link to clipboard

Copied

Setting a Time object on a Track Item object for both inPoint and outPoint fields throws an exception as well.

 

var inPoint = new Time();

inPoint.seconds = 1.3;

clip.inPoint = inPoint;

 

-- uncaught exception --

 

According to the docs (http://ppro.aenhancers.com/7%20-%20Track%20Item%20object/trackitem.html), the inPoint field on a Track Item object is: "Time object, read/write."


Tested on PP version 14.2.0

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jun 09, 2020 0
New Here ,
Jun 10, 2020

Copy link to clipboard

Copied

Hello everyone, 

I have an issue on trackItem.end and trackItem.start use too. 

And I don't understand in the declaration file (PremierePro.14.0.d.ts) .start and .end are declare as readonly. 

Is it normal ?

 

Thanks 🙂

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jun 10, 2020 0
Community Beginner ,
Jun 20, 2020

Copy link to clipboard

Copied

As of PP 14.3.0, setting a Time object on the start property for Track Item Object still throws:

 

Type error: cannot set property start

 

Wrapping the call in a try/catch seems to make the call work, but this may make the app state unstable.

 

When can we expect this will be fixed? It's a tablestakes API feature.

 

The docs say the start property is read/write: "Time object, read/write."

http://ppro.aenhancers.com/7%20-%20Track%20Item%20object/trackitem.html

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jun 20, 2020 1
Adobe Employee ,
Jun 22, 2020

Copy link to clipboard

Copied

Confirming: You can set the values within the Time object, but cannot replace the Time object with a different one, yes? 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jun 22, 2020 1
Community Beginner ,
Jun 23, 2020

Copy link to clipboard

Copied

Sure, but that has no effect: setting the ticks or seconds properties on a Time object that's already bound to an object does nothing.

 

trackItemObject.start.ticks = "10584000000" // does nothing

trackItemObject.start.seconds = 1.0 // does nothing

 

var t = new Time();
t.ticks = "10584000000";
trackItemObject.start = t; // throws Type error: cannot set property start

As it stands today (PP 14.3.0), it's impossible to modify the start, end, inPoint or outPoint properties on a trackItemObject in any way.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jun 23, 2020 2
Explorer ,
Sep 21, 2020

Copy link to clipboard

Copied

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?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 21, 2020 0
Adobe Employee ,
Sep 21, 2020

Copy link to clipboard

Copied

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

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 21, 2020 0
Explorer ,
Sep 21, 2020

Copy link to clipboard

Copied

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);

 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 21, 2020 0