automator-plus / tutorials

Code snippets and tutorials related to automating your Adobe workflow.
https://automatorplus.com
MIT License
40 stars 5 forks source link

Methods other than mute for tracks #33

Open louwjlabuschagne opened 3 years ago

louwjlabuschagne commented 3 years ago

On https://www.youtube.com/watch?v=LGabsGWvrUY&lc=Ugz9jNsycJ-lg9g7ql54AaABAg

OK ... can you instead of muting lock a specific track?

louwjlabuschagne commented 3 years ago

Yes you can, using the following:

// Get video tracks
videoTracks = app.project.activeSequence.videoTracks;

// Loop through video tracks
for (i = 0; i < videoTracks.numTracks; i++) {
  // videoTracks[i].setMute(1);
  // videoTracks[i].setTargeted(true, true);
  // videoTracks[i].setLocked(1);
}

Check out the video below to see it in action:

https://user-images.githubusercontent.com/10983628/125885775-e0b9c0fb-7476-458b-adc9-7518f29635f3.mp4

There are some subtleties with these methods... As you'll see, some of them take a boolean (true/false) and some an integer (1/0). This is what the API requires and there isn't much we can do about it, unfortunately. Usually what I do is try the one approach, i.e. boolean, and if I get the following error:

image

Try the other approach.

You'll see in the YouTube video I was using mute with a boolean, but in the video, in this comment, I'm using an integer. That's because in the YouTube video I was still running PP2020 (v14), and now I'm on PP2021 (v15) and it appears that the API has changed.

Keep in mind, you might not even notice this on your setup as Extendscript on certain machines will do the conversion for you, i.e boolean to integer and vice versa, so false will become 0 and true will become 1.

Another small thing to note is for the setTargeted method you'll see there are 2 arguments, the first one is the state you want to track to go to, the second is whether you want the GUI to refresh, i.e. show the change in PP. I can't think of a time when you wouldn't want to do it, so I advice keeping the second argument always set to true.

louwjlabuschagne commented 3 years ago

Code snippet in repo here.