Copy link to clipboard
Copied
I've written a ScriptUI toolbox to speed up intitial comp setups in our studio.
A typical comp might have 3 QuickTime layers in it…
"random_text_RMN.mov"
"random_text_JFK.mov"
"random_text_LBJ.mov"
All the text before the last three letters is subject to change. The last three letters (JFK, LBJ, etc) will always be present (and there's about 10 more files that I haven't listed).
I have a button that takes the active layer and applies a set of hard coded values to it (for position, scale, and anchor point). It works great, but I had to create a button for every possible QuickTime layer, which makes the toolbox huuuuge. I would like to improve this by having one button that simply reads the last portion of the layer source name then applies a set of unique scale, position, and anchor point values to it. I'm having a little trouble with the syntax though.
I assume I need something like…
app.beginUndoGroup("Auto Comp")
var character = app.project.activeItem.selectedLayers[0];
if (character == item.file.fsName.indexOf("JFK.mov") > -1) {
character.property("Anchor Point").setValue([2000,3020]);
character.transform.position.setValue([2126,3695]);
character.transform.scale.setValue([95,95]);
}
else if (character == item.file.fsName.indexOf("LBJ.mov") > -1) {
character.property("Anchor Point").setValue([2000,3600]);
character.transform.position.setValue([1267,2984]);
character.transform.scale.setValue([47,47]);
}
app.endUndoGroup();
but when I click the button with the correct layer selected, nothing happens. I probably did something dumb. 😞
Any help would be appreciated! Thanks
I think maybe you just need to check the name of the layer, like this:
if (character.name.indexOf("JFK.mov") > -1) {
Dan
Copy link to clipboard
Copied
I think what you are looking for is the includes() method of strings.
*Martin
Copy link to clipboard
Copied
Thanks. I'm fairly new to this. I've edited the post with some updated code, but the syntax is wrong. nothing happens when i click the button with the correct layer selected.
Copy link to clipboard
Copied
I think maybe you just need to check the name of the layer, like this:
if (character.name.indexOf("JFK.mov") > -1) {
Dan
Copy link to clipboard
Copied
Thanks Dan! Totally worked.