Get layer comp index?

Discussion of Photoshop Scripting, Photoshop Actions and Photoshop Automation in General

Moderators: Tom, Kukurykus

alexouros
Posts: 3
Joined: Sat Nov 03, 2018 7:54 pm

Get layer comp index?

Post by alexouros »

Hi, I have this script to get the currently selected layer comp's index (this is a section of it)

Code: Select all

for( var c = 0; c < doc.layerComps.length; c++ ){
if( doc.layerComps[c].selected == true ){
currentLayerCompID = c;
break;
}
}
The problem is I have over a thousand layer comps so this script takes a very long time to finish. Is there a way to get the ID without going through the whole list?
Thanks!


And a bonus question, is there a way to create a new layer comp and position it right after the one that's currently selected? Because LayerComp.add makes one at the end of the list.
Last edited by alexouros on Mon Nov 05, 2018 12:57 am, edited 1 time in total.
User avatar
Kukurykus
Posts: 528
Joined: Mon Jul 25, 2016 12:36 pm

Re: Get layer comp index?

Post by Kukurykus »

Yes it is possible to do it within a half of second for 1000 layer comps, so about 30 times faster. For the applied one that would be even faster.

So that can be done surely in less than about 15 seconds, depending on one's processor. But why you have so many layer comps, 1000, really?

The bonus question is also accomplishable, so making next layer comp as consecutive to selected one than the last one that is set by default.

If you are dedicated to show here again, so not like others after writing a script for, going to vanish, send me PM to let me know about... ;)
alexouros
Posts: 3
Joined: Sat Nov 03, 2018 7:54 pm

Re: Get layer comp index?

Post by alexouros »

Haha no, not going to ask a question and vanish. The reason I have a thousand layers is because I’m a storyboard artist and a thousand layers usually translate to about 200-300 panels which would be about 2-4 minutes of screen time. So right now I’m trying to find ways how scripts can improve my storyboarding workflow in photoshop.
User avatar
Kukurykus
Posts: 528
Joined: Mon Jul 25, 2016 12:36 pm

Re: Get layer comp index?

Post by Kukurykus »

Okey script is sent, however I'm not sure I understand futher process so dividing layers into 250 panels (what I don't know what they are) and have you meant 1000 layer comps, so not just layers?
alexouros
Posts: 3
Joined: Sat Nov 03, 2018 7:54 pm

Re: Get layer comp index?

Post by alexouros »

Hey if there're other people who aren't asking $50 for some simple help, I'd really appreciate is someone could let me know how I could get layer comp index with javascript?