Copy link to clipboard
Copied
Hello Everyone,
I've been trying to run the following script on only the channels I currently have selected. However, no matter what I put in, I cannot get it to run on only those channels I have selected. Can anyone help? I'm sure it's probably the simplest thing but I've been pulling my hair out over this.
var doc = app.activeDocument;
for(var channelIndex = 0; channelIndex<doc.channels.length; channelIndex++){
if(doc.channels[channelIndex].kind == ChannelType.MASKEDAREA||
doc.channels[channelIndex].kind == ChannelType.SELECTEDAREA){
doc.channels[channelIndex].kind = ChannelType.SPOTCOLOR;
}
}
You are running the script on all channels not selected channels, example of selected channels.
var alist = activeDocument.activeChannels;
for(var a =0;a<alist.length;a++){
$.writeln(alist.kind + " " + alist.name);
}
Copy link to clipboard
Copied
You are running the script on all channels not selected channels, example of selected channels.
var alist = activeDocument.activeChannels;
for(var a =0;a<alist.length;a++){
$.writeln(alist.kind + " " + alist.name);
}
Copy link to clipboard
Copied
SuperMerlin​ Thank you so much for the guidance! I've changed it using your suggestion and it's working now. The process seems to take a bit long but it's working as expected.
var doc = app.activeDocument;
var alist = doc.activeChannels;
for(var a = 0; a<alist.length;a++){
if(alist.kind != ChannelType.SPOTCOLOR ){
alist.kind = ChannelType.SPOTCOLOR;
}
}
Does your suggested script also rename the selected channels in sequential order? For example, could I use that to append '01', '02', '03' and so on sequentially to the beginning of the channels while keeping the channels' existing names behind the numbers?
Copy link to clipboard
Copied
Yes..
var alist = activeDocument.activeChannels;
for(var a =0;a<alist.length;a++){
alist.name = "0" + (a+1) + alist.name;
}
Find more inspiration, events, and resources on the new Adobe Community
Explore Now