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

modify this code to (addtoselection)

Enthusiast ,
May 08, 2024 May 08, 2024

Copy link to clipboard

Copied

Hello everyone and greetings to you
I found this code, which is for creating a selection for the selected layer
I want to modify the code to add another selection to the current selection
Meaning that I already have a layer selected and I want to select another layer next to the current selection
How can we help with this?
Thank you


selectActivePixels
()
function cID (inVal) { return charIDToTypeID(inVal);}
function sID (inVal) { return stringIDToTypeID(inVal);}

function selectActivePixels(){
    var desc15 = new ActionDescriptor();
    var ref8 = new ActionReference();
    ref8.putProperty( cID( "Chnl" ), cID( "fsel" ) );
    desc15.putReference( cID( "null" ), ref8 );
    var ref9 = new ActionReference();
    ref9.putEnumerated( cID( "Chnl" ), cID( "Chnl" ), cID( "Trsp" ) );
    desc15.putReference( cID( "T   " ), ref9 );
    executeAction( cID( "setd" ), desc15, DialogModes.NO );
}
TOPICS
Actions and scripting , Windows

Views

143

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 2 Correct answers

Enthusiast , May 08, 2024 May 08, 2024
Well, I discovered where the problem was and solved it
Thank you for your interest in the matter

function
cID (inVal) { return charIDToTypeID(inVal);}
function sID (inVal) { return stringIDToTypeID(inVal);}

function intersectActivePixels()
{
    var desc18 = new ActionDescriptor();
    var ref13 = new ActionReference();
    ref13.putEnumerated( cID( "Chnl" ), cID( "Chnl" ), cID( "Trsp" ) );
    desc18.putReference( cID( "null" ), ref13 );
    var ref14 = new ActionReference();
    ref14.putProperty( cID( "
...

Votes

Translate

Translate
Community Expert , May 08, 2024 May 08, 2024

I'm sure that @r-bin has set you right, this is what I would have done using cleaned ScriptingListener code for the new selected/active layer:

 

addLayerSelToSel();

function addLayerSelToSel() {
	var s2t = function (s) {
		return app.stringIDToTypeID(s);
	};
	var descriptor = new ActionDescriptor();
	var reference = new ActionReference();
	var reference2 = new ActionReference();
	reference.putEnumerated( s2t( "channel" ), s2t( "channel" ), s2t( "transparencyEnum" ));
	descriptor.putReference( s
...

Votes

Translate

Translate
Adobe
Community Expert ,
May 08, 2024 May 08, 2024

Copy link to clipboard

Copied

Please post before and after screenshots of the layers panel to clearly illustrate the layer kinds, visibility and positions.

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
Enthusiast ,
May 08, 2024 May 08, 2024

Copy link to clipboard

Copied

01.jpg02.jpg
In the first image, a layer selection was created using code
I want to modify the code to add another selection next to the current selection that exists when selecting another layer

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
People's Champ ,
May 08, 2024 May 08, 2024

Copy link to clipboard

Copied

Where you found it is the intersectActivePixels() function.

Replace cID("Intr") with cID("Add ").

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
Enthusiast ,
May 08, 2024 May 08, 2024

Copy link to clipboard

Copied

Well, I discovered where the problem was and solved it
Thank you for your interest in the matter

function
cID (inVal) { return charIDToTypeID(inVal);}
function sID (inVal) { return stringIDToTypeID(inVal);}

function intersectActivePixels()
{
    var desc18 = new ActionDescriptor();
    var ref13 = new ActionReference();
    ref13.putEnumerated( cID( "Chnl" ), cID( "Chnl" ), cID( "Trsp" ) );
    desc18.putReference( cID( "null" ), ref13 );
    var ref14 = new ActionReference();
    ref14.putProperty( cID( "Chnl" ), cID( "fsel" ) );
    desc18.putReference( cID( "With" ), ref14 );
    executeAction( cID( "Add " ), desc18, DialogModes.NO );
}

intersectActivePixels()

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 ,
May 08, 2024 May 08, 2024

Copy link to clipboard

Copied

LATEST

I'm sure that @r-bin has set you right, this is what I would have done using cleaned ScriptingListener code for the new selected/active layer:

 

addLayerSelToSel();

function addLayerSelToSel() {
	var s2t = function (s) {
		return app.stringIDToTypeID(s);
	};
	var descriptor = new ActionDescriptor();
	var reference = new ActionReference();
	var reference2 = new ActionReference();
	reference.putEnumerated( s2t( "channel" ), s2t( "channel" ), s2t( "transparencyEnum" ));
	descriptor.putReference( s2t( "null" ), reference );
	reference2.putProperty( s2t( "channel" ), s2t( "selection" ));
	descriptor.putReference( s2t( "to" ), reference2 );
	executeAction( s2t( "add" ), descriptor, DialogModes.NO );
}

 

 

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