Highlighted

How do I use an array in a variable?

Explorer ,
Oct 13, 2020

Copy link to clipboard

Copied

I have a script which looks for a layer named "Car" and gets its position value. However, I also need it to look for other names and case variations, just in case "Car" doesn't exist. eg - "CAR" "Truck" "TRUCK", etc

 

The line in question is this…

 

var pos = app.project.activeItem.layer("Car").transform.position.value;

 

 

What's the correct syntax for changing that line into an array that would look for all possible variations above?

I tried this, but it's obviously wrong because it doesn't work…

 

var pos = app.project.activeItem.layer(["Car","CAR","Truck","TRUCK"]).transform.position.value;

 

 

TOPICS
Scripting

Views

27

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

How do I use an array in a variable?

Explorer ,
Oct 13, 2020

Copy link to clipboard

Copied

I have a script which looks for a layer named "Car" and gets its position value. However, I also need it to look for other names and case variations, just in case "Car" doesn't exist. eg - "CAR" "Truck" "TRUCK", etc

 

The line in question is this…

 

var pos = app.project.activeItem.layer("Car").transform.position.value;

 

 

What's the correct syntax for changing that line into an array that would look for all possible variations above?

I tried this, but it's obviously wrong because it doesn't work…

 

var pos = app.project.activeItem.layer(["Car","CAR","Truck","TRUCK"]).transform.position.value;

 

 

TOPICS
Scripting

Views

28

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
Oct 13, 2020 0
Explorer ,
Oct 13, 2020

Copy link to clipboard

Copied

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...
Oct 13, 2020 0