How to select mulitple artlayers simultaneously?
Can somenoe help me out?
How to select mulitple artlayers simultaneously?
How to select mulitple artlayers simultaneously?
Bonjour
By using ScriptingListenerJS.log - AddToSelection
Something like this:
Code: Select allactiveDocument.activeLayer = activeDocument.layers[3]; // calque actif
SelCalc1 = activeDocument.layers[1].name; // pour ajout
SelCalc2 = activeDocument.layers[2].name; // idem
addCalc(SelCalc1);
addCalc(SelCalc2);
function addCalc( selCalc )
{
var idslct = charIDToTypeID( "slct" );
var desc7 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
var ref5 = new ActionReference();
var idLyr = charIDToTypeID( "Lyr " );
ref5.putName( idLyr, selCalc );
desc7.putReference( idnull, ref5 );
var idselectionModifier = stringIDToTypeID( "selectionModifier" );
var idselectionModifierType = stringIDToTypeID( "selectionModifierType" );
var idaddToSelection = stringIDToTypeID( "addToSelection" );
desc7.putEnumerated( idselectionModifier, idselectionModifierType, idaddToSelection );
var idMkVs = charIDToTypeID( "MkVs" );
desc7.putBoolean( idMkVs, false );
executeAction( idslct, desc7, DialogModes.NO );
}
By using ScriptingListenerJS.log - AddToSelection
Something like this:
Code: Select allactiveDocument.activeLayer = activeDocument.layers[3]; // calque actif
SelCalc1 = activeDocument.layers[1].name; // pour ajout
SelCalc2 = activeDocument.layers[2].name; // idem
addCalc(SelCalc1);
addCalc(SelCalc2);
function addCalc( selCalc )
{
var idslct = charIDToTypeID( "slct" );
var desc7 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
var ref5 = new ActionReference();
var idLyr = charIDToTypeID( "Lyr " );
ref5.putName( idLyr, selCalc );
desc7.putReference( idnull, ref5 );
var idselectionModifier = stringIDToTypeID( "selectionModifier" );
var idselectionModifierType = stringIDToTypeID( "selectionModifierType" );
var idaddToSelection = stringIDToTypeID( "addToSelection" );
desc7.putEnumerated( idselectionModifier, idselectionModifierType, idaddToSelection );
var idMkVs = charIDToTypeID( "MkVs" );
desc7.putBoolean( idMkVs, false );
executeAction( idslct, desc7, DialogModes.NO );
}
How to select mulitple artlayers simultaneously?
txuku wrote:Bonjour
By using ScriptingListenerJS.log - AddToSelection
Something like this:
[/code]
Tks txuku
The codes works well if the layer name is unique.
The codes manipulate the layers by their name,if there are different layers in different layersets but with same name.The codes above can't work as you wish.
By using ScriptingListenerJS.log - AddToSelection
Something like this:
[/code]
Tks txuku
The codes works well if the layer name is unique.
The codes manipulate the layers by their name,if there are different layers in different layersets but with same name.The codes above can't work as you wish.
How to select mulitple artlayers simultaneously?
The codes above can't work as you wish.
Don’t you mean
The codes above can't work as I wish.
?
You have not explained how you want to identify the layers.
Either Paul or Mike (or both) have provided cows to select multiple layers via the index.
Code: Select all// by mike hale, via paul riggott;
// http://forums.adobe.com/message/1944754#1944754
function selectLayerByIndex(index,add){
add = undefined ? add = false:add
var ref = new ActionReference();
ref.putIndex(charIDToTypeID("Lyr "), index);
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){
alert(e.message);
}
};
Don’t you mean
The codes above can't work as I wish.
?
You have not explained how you want to identify the layers.
Either Paul or Mike (or both) have provided cows to select multiple layers via the index.
Code: Select all// by mike hale, via paul riggott;
// http://forums.adobe.com/message/1944754#1944754
function selectLayerByIndex(index,add){
add = undefined ? add = false:add
var ref = new ActionReference();
ref.putIndex(charIDToTypeID("Lyr "), index);
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){
alert(e.message);
}
};
How to select mulitple artlayers simultaneously?
[quote="pfaffenbichler"][quote]
Thank you very much,pfaffenbichle.I just want to know if there is a flexiable way.Actually ,txuku's code works well for me .
tks you all.
Thank you very much,pfaffenbichle.I just want to know if there is a flexiable way.Actually ,txuku's code works well for me .
tks you all.
How to select mulitple artlayers simultaneously?
I was just playing around with this, and I though that the layer index was unique to that layer and didn't change, but I moved some layers around and the index changes. Is there some way to get a unique identifier for a layer that doesn't change, so that you can reselect that and multiple other layer after they've been moved?
How to select mulitple artlayers simultaneously?
I these are some functions you can use to get the selected layers Id and select multiple by Id.
Code: Select allfunction getSelectedLayersIds(){// get the selected layers identifiers
//( these id's are unique and they will not change if the layer name is changed or it's position in the layers editor will change)
var idxs = getSelectedLayersIdx();// first get the indexes
var selectedLayersIds = [];
//for each index get the layer id
for( var i=0;i<idxs.length;i++){
selectedLayersIds.push(getIdfromIdx(idxs));
}
return selectedLayersIds;
}
function hasBackground(){// function to check if there is a background layer
var res = undefined;
try{
var ref = new ActionReference();
ref.putProperty( charIDToTypeID("Prpr") , charIDToTypeID("Nm "));
ref.putIndex( charIDToTypeID("Lyr "), 0 );
executeActionGet(ref).getString(charIDToTypeID("Nm ") );
res = true;
}catch(e){ res = false}
return res;
}
function getIdfromIdx( idx ){// get the id from index
var ref = new ActionReference();
ref.putIndex(charIDToTypeID('Lyr '), idx);
var desc = executeActionGet(ref);
desc = desc.getInteger(charIDToTypeID("LyrI"));
return desc;
}
function getSelectedLayersIdx(){// get the selected layers index( positon in layer editor)
var selectedLayers = new Array;
var ref = new ActionReference();
ref.putEnumerated( charIDToTypeID('Dcmn'), charIDToTypeID('Ordn'), charIDToTypeID('Trgt') );
var desc = executeActionGet(ref);
var add = 1;
if(hasBackground()){alert('hBck');add = 0}
if( desc.hasKey( stringIDToTypeID( 'targetLayers' ) ) ){
desc = desc.getList( stringIDToTypeID( 'targetLayers' ));
var c = desc.count
var selectedLayers = new Array();
for(var i=0;i<c;i++){
selectedLayers.push( (desc.getReference( i ).getIndex()) + add);
}
}else{
var ref = new ActionReference();
ref.putProperty( charIDToTypeID('Prpr') , charIDToTypeID( 'ItmI' ));
ref.putEnumerated( charIDToTypeID('Lyr '), charIDToTypeID('Ordn'), charIDToTypeID('Trgt') );
srs = hasBackground()?executeActionGet(ref).getInteger(charIDToTypeID( 'ItmI' ))-1:executeActionGet(ref).getInteger(charIDToTypeID( 'ItmI' ));
selectedLayers.push( srs);
}
return selectedLayers;
}
function doesIdExists( id ){// function to check if the id exists
var res = true;
var ref = new ActionReference();
ref.putIdentifier(charIDToTypeID('Lyr '), id);
try{var desc = executeActionGet(ref)}catch(err){res = false};
return res;
}
function multiSelectByIDs(ids) {
if( ids.constructor != Array ) ids = [ ids ];
var layers = new Array();
var id54 = charIDToTypeID( "slct" );
var desc12 = new ActionDescriptor();
var id55 = charIDToTypeID( "null" );
var ref9 = new ActionReference();
for (var i = 0; i < ids.length; i++) {
if(doesIdExists(ids) == true){// a check to see if the id stil exists
layers = charIDToTypeID( "Lyr " );
ref9.putIdentifier(layers, ids);
}
}
desc12.putReference( id55, ref9 );
var id58 = charIDToTypeID( "MkVs" );
desc12.putBoolean( id58, false );
executeAction( id54, desc12, DialogModes.NO );
}
Code: Select allfunction getSelectedLayersIds(){// get the selected layers identifiers
//( these id's are unique and they will not change if the layer name is changed or it's position in the layers editor will change)
var idxs = getSelectedLayersIdx();// first get the indexes
var selectedLayersIds = [];
//for each index get the layer id
for( var i=0;i<idxs.length;i++){
selectedLayersIds.push(getIdfromIdx(idxs));
}
return selectedLayersIds;
}
function hasBackground(){// function to check if there is a background layer
var res = undefined;
try{
var ref = new ActionReference();
ref.putProperty( charIDToTypeID("Prpr") , charIDToTypeID("Nm "));
ref.putIndex( charIDToTypeID("Lyr "), 0 );
executeActionGet(ref).getString(charIDToTypeID("Nm ") );
res = true;
}catch(e){ res = false}
return res;
}
function getIdfromIdx( idx ){// get the id from index
var ref = new ActionReference();
ref.putIndex(charIDToTypeID('Lyr '), idx);
var desc = executeActionGet(ref);
desc = desc.getInteger(charIDToTypeID("LyrI"));
return desc;
}
function getSelectedLayersIdx(){// get the selected layers index( positon in layer editor)
var selectedLayers = new Array;
var ref = new ActionReference();
ref.putEnumerated( charIDToTypeID('Dcmn'), charIDToTypeID('Ordn'), charIDToTypeID('Trgt') );
var desc = executeActionGet(ref);
var add = 1;
if(hasBackground()){alert('hBck');add = 0}
if( desc.hasKey( stringIDToTypeID( 'targetLayers' ) ) ){
desc = desc.getList( stringIDToTypeID( 'targetLayers' ));
var c = desc.count
var selectedLayers = new Array();
for(var i=0;i<c;i++){
selectedLayers.push( (desc.getReference( i ).getIndex()) + add);
}
}else{
var ref = new ActionReference();
ref.putProperty( charIDToTypeID('Prpr') , charIDToTypeID( 'ItmI' ));
ref.putEnumerated( charIDToTypeID('Lyr '), charIDToTypeID('Ordn'), charIDToTypeID('Trgt') );
srs = hasBackground()?executeActionGet(ref).getInteger(charIDToTypeID( 'ItmI' ))-1:executeActionGet(ref).getInteger(charIDToTypeID( 'ItmI' ));
selectedLayers.push( srs);
}
return selectedLayers;
}
function doesIdExists( id ){// function to check if the id exists
var res = true;
var ref = new ActionReference();
ref.putIdentifier(charIDToTypeID('Lyr '), id);
try{var desc = executeActionGet(ref)}catch(err){res = false};
return res;
}
function multiSelectByIDs(ids) {
if( ids.constructor != Array ) ids = [ ids ];
var layers = new Array();
var id54 = charIDToTypeID( "slct" );
var desc12 = new ActionDescriptor();
var id55 = charIDToTypeID( "null" );
var ref9 = new ActionReference();
for (var i = 0; i < ids.length; i++) {
if(doesIdExists(ids) == true){// a check to see if the id stil exists
layers = charIDToTypeID( "Lyr " );
ref9.putIdentifier(layers, ids);
}
}
desc12.putReference( id55, ref9 );
var id58 = charIDToTypeID( "MkVs" );
desc12.putBoolean( id58, false );
executeAction( id54, desc12, DialogModes.NO );
}
How to select mulitple artlayers simultaneously?
c.buliarca wrote:I these are some functions you can use to get the selected layers Id and select multiple by Id.
Thanks, this does work. I guess the script I was using just got the idx and not the id.
Thanks, this does work. I guess the script I was using just got the idx and not the id.