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

Select alpha channel with specific name

Engaged ,
Jul 21, 2021 Jul 21, 2021

Copy link to clipboard

Copied

How i can select alpha channel with specific name, using javascript? I work with CMYK images and i want to select alpha channel which is often caled (trap, Trap selection, selection for trap, etc.), keyword is TRAP but other parts of alpha channel name depends of users... 

 

Thanks in advance!

TOPICS
Actions and scripting , macOS

Views

675

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
community guidelines

correct answers 1 Correct answer

LEGEND , Jul 27, 2021 Jul 27, 2021

The reason I couldn't understand what you want is that the thread you started was originally about manipulating selections in the panels, so when later, after few days you said 'to make selection of alpha channel' I was sure you refer to the core of very first question, not to the selection of channel on document canvas.

aD = activeDocument
if (alphs = [].slice.call(aD.channels)
.splice(aD.componentChannels.length)) {	
	trapChannel = false; while(alphs.length) {
		splt.visible = /trap/i.test(nme
...

Votes

Translate

Translate
Adobe
LEGEND ,
Jul 21, 2021 Jul 21, 2021

Copy link to clipboard

Copied

 

with(activeDocument) channels.length > 4
&& /trap/i.test(nme = channels[4].name) &&
activeChannels = [channels.getByName(nme)]

 

Votes

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
community guidelines
Engaged ,
Jul 21, 2021 Jul 21, 2021

Copy link to clipboard

Copied

This works perfectly, but i forgot to mention that my files sometimes contains one or more spot colors, how to improve this part? Thanks

Votes

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
community guidelines
LEGEND ,
Jul 21, 2021 Jul 21, 2021

Copy link to clipboard

Copied

 

chnnls = (aD = activeDocument).channels
if (alphs = [].slice.call(chnnls).splice(4)) {
	brk = false; while(!brk && alphs.length) {
		if (/trap/i.test(nme = (splt = alphs.shift()).name))
			brk = aD.activeChannels = [chnnls.getByName(nme)]
	}
}

 

Votes

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
community guidelines
Engaged ,
Jul 21, 2021 Jul 21, 2021

Copy link to clipboard

Copied

Perfect! Thanks a lot!

Votes

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
community guidelines
Engaged ,
Jul 27, 2021 Jul 27, 2021

Copy link to clipboard

Copied

Could you please change code to show other channels, basically my needs are to display all channels (CMYK and spot colours) and just to make selection of alpha channel with keyword "trap"? Thanks in advance

 

Screenshot 2021-07-27 at 12.05.29.png  Screenshot 2021-07-27 at 12.05.35.png

Votes

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
community guidelines
LEGEND ,
Jul 27, 2021 Jul 27, 2021

Copy link to clipboard

Copied

Your image doesn't fit the description. On image I see component channels are displayed and selected, while spot channel is not displayed and not selected. Explain it... Regarding your text you can't have component channels and spot channel selected at same time, only dispayed.

Votes

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
community guidelines
Engaged ,
Jul 27, 2021 Jul 27, 2021

Copy link to clipboard

Copied

Ok, sometimes my pictures are just CMYK and sometimes they contain spot channels. Is it possible to make a universal solution (or two solututions one for CMYK one for multichannel) that will select all channels and make a selection of the mentioned alpha channel?

Thank you for your dedication

 

Screenshot 2021-07-27 at 13.07.43.png  Screenshot 2021-07-27 at 13.07.50.png

Votes

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
community guidelines
LEGEND ,
Jul 27, 2021 Jul 27, 2021

Copy link to clipboard

Copied

There's an inconsistency in your request. You post now an image in multichannel mode with displayed and selected remains of CMYK channels and the spot channel. 'trap' alpha channel is undisplayed and unselected.

 

In your current description you say to select all channels and 'mentioned alpha channel'. The mentioned alpha channel I understand is that you mentioned in previous post where you said 'to make selection of alpha channel with keyword "trap"'.

 

You again post channels tree that can't be compared to your text. You want to select alpha channel 'trap' along with other channels and spots and then attach an image that shows only alpha channel 'trap' is unselected ðŸ˜•

 

Do you think I can understand what you really want?

 

Ps. usually screenshots are posted to illustrate expected result, but yours make confusion.

Votes

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
community guidelines
Engaged ,
Jul 27, 2021 Jul 27, 2021

Copy link to clipboard

Copied

Dear, images exactly ilustrate final result, please look up closly, on the second image you can find selection of alpha channel (selection on border, between glass of milk and bg) .The idea is that in both cases needs are to display and mark cmyk(cmyk +spot) channels with selection of alpha channel (trap)?

I apologize for the misunderstanding

Votes

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
community guidelines
LEGEND ,
Jul 27, 2021 Jul 27, 2021

Copy link to clipboard

Copied

The reason I couldn't understand what you want is that the thread you started was originally about manipulating selections in the panels, so when later, after few days you said 'to make selection of alpha channel' I was sure you refer to the core of very first question, not to the selection of channel on document canvas.

aD = activeDocument
if (alphs = [].slice.call(aD.channels)
.splice(aD.componentChannels.length)) {	
	trapChannel = false; while(alphs.length) {
		splt.visible = /trap/i.test(nme = (splt = alphs.shift()).name) && !trapChannel
		? !(trapChannel = true, sTT = stringIDToTypeID, (ref1 = new ActionReference())
		.putProperty(chnnl = sTT('channel'), sTT('selection')), (dsc = new ActionDescriptor())
		.putReference(sTT('null'), ref1), (ref2 = new ActionReference()).putName(chnnl, nme),
		dsc.putReference(sTT('to'), ref2), executeAction(sTT('set'), dsc)) : true
	}
}

Votes

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
community guidelines
Community Expert ,
Jul 27, 2021 Jul 27, 2021

Copy link to clipboard

Copied

Yeah, that got me too... It would have helped if Adobe used the term "target" when dealing with "selecting channels or layers" in their respective panels, rather than a "select"... Too many selections!

Votes

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
community guidelines
Engaged ,
Jul 27, 2021 Jul 27, 2021

Copy link to clipboard

Copied

Thanks @Kukurykus, sorry for misunderstanding, I will mark last code as correct answer

Votes

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
community guidelines
Engaged ,
Sep 14, 2022 Sep 14, 2022

Copy link to clipboard

Copied

LATEST

Dear @Kukurykus could you improve this script, how to alert user if this kind of alpha channel does not exist? Thanks in advance

 

Votes

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
community guidelines