I've been looking into doing a script that simply selects all alpha/spot channels and can't figure it out. Needs to select them all regardless of name or number of channels.
Edit:
So, I figured out the following will select all the component channels. Still trying to work out how to also select "all" the Spot or Alpha channels.
Code: Select allapp.activeDocument.activeChannels =
activeDocument.componentChannels
Edit 2
Well, here's how to delete all Spot or Alpha channels. Still can't figure out how to select them all?
Code: Select allapp.bringToFront();
var theImage = app.activeDocument;
theImage.channels.removeAll();
Script To Select All Channels?
Script To Select All Channels?
Active channels will expect an array I think. So you would need to check the document color mode first then count the non-component channels… So using the indexes
Code: Select allvar doc = app.activeDocument;
doc.activeChannels = [doc.channels[4],doc.channels[5]];
Would select the 5th & 6th channels… but they would need to exist…
Code: Select allvar doc = app.activeDocument;
doc.activeChannels = [doc.channels[4],doc.channels[5]];
Would select the 5th & 6th channels… but they would need to exist…
Script To Select All Channels?
Yes, that wouldn't work since the document would need to contain the exact number of Channels the script is targeting. The way I see it, if a simple script can be written to delete all channels regardless of number, then one can surely be done which selects all channels. Been working on this all day and still can't figure it out. Although I admit to being a novice at the moment.
Script To Select All Channels?
ActiveChannels is the way to select the channels. You just have to look through the channels and store the ones you want to select in an array.
Code: Select allvar channelArray = [];
for(var c = 0; c < app.activeDocument.channels.length;c++ ){
if( (app.activeDocument.channels[c].kind == ChannelType.SPOTCOLOR) || (app.activeDocument.channels[c].kind == ChannelType.MASKEDAREA) ){
channelArray.push( app.activeDocument.channels[c] );
}
}
app.activeDocument.activeChannels = channelArray;
Code: Select allvar channelArray = [];
for(var c = 0; c < app.activeDocument.channels.length;c++ ){
if( (app.activeDocument.channels[c].kind == ChannelType.SPOTCOLOR) || (app.activeDocument.channels[c].kind == ChannelType.MASKEDAREA) ){
channelArray.push( app.activeDocument.channels[c] );
}
}
app.activeDocument.activeChannels = channelArray;
Script To Select All Channels?
Can't thank you enough Mike. Would have been struggling with that one forever. There was more to it than I originally thought.
Script To Select All Channels?
Mike, I would have done this the other way over… or did I miss something…?
Code: Select allvar channelArray = [];
for ( var c = app.activeDocument.channels.length-1; c >= 0; c-- ) {
if ( app.activeDocument.channels[c].kind != ChannelType.COMPONENT ) {
channelArray.push( app.activeDocument.channels[c] );
}
}
app.activeDocument.activeChannels = channelArray;
Not sure if its worth breaking out at first component?
Code: Select allvar channelArray = [];
for ( var c = app.activeDocument.channels.length-1; c >= 0; c-- ) {
if ( app.activeDocument.channels[c].kind != ChannelType.COMPONENT ) {
channelArray.push( app.activeDocument.channels[c] );
}
}
app.activeDocument.activeChannels = channelArray;
Not sure if its worth breaking out at first component?
Script To Select All Channels?
I'm not sure it makes much difference which order the channels are tested. But as long as the loop starts at the bottom of the channel stack I think I would add the break.