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

How can I select Layers by ID

Contributor ,
Apr 14, 2016 Apr 14, 2016

Copy link to clipboard

Copied

My HTML extension panel listening to JSONEvents, like this SELECT:

{ "eventID": 1936483188, "eventData": {"layerID":[2,97],"makeVisible":false,"null":{"_name":"back1.jpg","_ref":"layer"},"selectionModifier":{"_enum":"selectionModifierType","_value":"addToSelectionContinuous"}}}

In the event handler, the script is storing the selected layer's "layerID"s to an array.

How can I select these layers again later by the stored IDs with a .jsx call?

Must be simple, but i can't find a way.

Is it possible to convert the layer ID to Index?

Thanks a lot!

TOPICS
Actions and scripting

Views

1.4K

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

Guide , Apr 14, 2016 Apr 14, 2016

selectLayerById(98); //select this layer only

selectLayerById(80,true); //select this layer along with other selected layers

function selectLayerById(id,add){

var ref = new ActionReference();

ref.putIdentifier(charIDToTypeID('Lyr '), id);

var desc = new ActionDescriptor();

desc.putReference(charIDToTypeID("null"), ref );

if(add) desc.putEnumerated( stringIDToTypeID( "selectionModifier" ), stringIDToTypeID( "selectionModifierType" ), stringIDToTypeID( "addToSelection" ) );

desc.putBoolean( ch

...

Votes

Translate

Translate
Adobe
Guide ,
Apr 14, 2016 Apr 14, 2016

Copy link to clipboard

Copied

selectLayerById(98); //select this layer only

selectLayerById(80,true); //select this layer along with other selected layers

function selectLayerById(id,add){

var ref = new ActionReference();

ref.putIdentifier(charIDToTypeID('Lyr '), id);

var desc = new ActionDescriptor();

desc.putReference(charIDToTypeID("null"), ref );

if(add) desc.putEnumerated( stringIDToTypeID( "selectionModifier" ), stringIDToTypeID( "selectionModifierType" ), stringIDToTypeID( "addToSelection" ) );

desc.putBoolean( charIDToTypeID( "MkVs" ), false );

try{

executeAction(charIDToTypeID("slct"), desc, DialogModes.NO );

}catch(e){}

};


					
				
			
			
				
			
			
			
			
			
			
			
		

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
Contributor ,
Apr 14, 2016 Apr 14, 2016

Copy link to clipboard

Copied

LATEST

Many Thanks SuperMerlin! It's working fine.

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