Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Changing Selected Channels' channelType

New Here ,
Mar 04, 2017 Mar 04, 2017

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;

    }

}

TOPICS
Actions and scripting
626
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Guide , Mar 04, 2017 Mar 04, 2017

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);

    }

Translate
Adobe
Guide ,
Mar 04, 2017 Mar 04, 2017

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);

    }

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 05, 2017 Mar 05, 2017

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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Mar 05, 2017 Mar 05, 2017
LATEST

Yes..

var alist =  activeDocument.activeChannels;

for(var a =0;a<alist.length;a++){

    alist.name = "0" + (a+1)  + alist.name;

    }

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines