Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
selectTransparency();
function selectTransparency() {
function cTID(s) { return app.charIDToTypeID(s); };
function sTID(s) { return app.stringIDToTypeID(s); };
var desc27 = new ActionDescriptor();
var ref3 = new ActionReference();
ref3.putProperty( cTID('Chnl'), cTID('fsel') );
desc27.putReference( cTID('null'), ref3 );
var ref4 = new ActionReference();
ref4.putEnumerated( cTID('Chnl'), cTID('Chnl'), cTID('Trsp') );
desc27.putReference( cTID('T '), ref4 );
executeAction( cTID('setd'), desc27, DialogModes.NO );
};
Copy link to clipboard
Copied
I'm trying to do the same thing and got the code working, but I would also like to specify the mode when selecting.
Specifically I would like to add the transparencys from several layers together to get their combined transparency. In other words, the equivalent of CTRL-SHIFT-Click on the layer thumbnail.
How would I do this?
thanks
Ludde
Copy link to clipboard
Copied
Give this a try....
loadTransparencyAll();
function loadTransparencyAll() {
var desc13 = new ActionDescriptor();
var ref10 = new ActionReference();
ref10.putProperty( charIDToTypeID('Chnl'), charIDToTypeID('fsel') );
desc13.putReference( charIDToTypeID('null'), ref10 );
var ref11 = new ActionReference();
ref11.putEnumerated( charIDToTypeID('Chnl'), charIDToTypeID('Chnl'), charIDToTypeID('Trsp') );
ref11.putName( charIDToTypeID('Lyr '), activeDocument.artLayers[0].name );
desc13.putReference( charIDToTypeID('T '), ref11 );
try{
executeAction( charIDToTypeID('setd'), desc13, DialogModes.NO );
}catch(e){}
};
Copy link to clipboard
Copied
The function below will add a layer trans to the selection like ctrl-shift-clicking in the layers icon. Note there needs to be an active selection so use the other function posted to load one layer trans then use the function below to add as many layers as you need.
function addLayerTransToSelection( layerName ){
try{
var desc = new ActionDescriptor();
var ref = new ActionReference();
ref.putEnumerated( charIDToTypeID( "Chnl" ), charIDToTypeID( "Chnl" ), charIDToTypeID( "Trsp" ) );
ref.putName( charIDToTypeID( "Lyr " ), layerName );
desc.putReference( charIDToTypeID( "null" ), ref );
var ref1 = new ActionReference();
ref1.putProperty( charIDToTypeID( "Chnl" ), charIDToTypeID( "fsel" ) );
desc.putReference( charIDToTypeID( "T " ), ref1 );
executeAction( charIDToTypeID( "Add " ), desc, DialogModes.NO );
return true;
}catch(e){}
return false;
}
Copy link to clipboard
Copied
Thanks, this seems to be working except for one thing. If two or more layers have the same name only one of them gets selected.
How should I do to use a reference to the layer instead of the name?
thanks
/Ludde
Copy link to clipboard
Copied
You can not use a scripting API reference when working with action manager API. You could add by index, but the action manager index for a layer is not the same as the scripting layer index.
If your workflow allows you could make the layer you want to add active, get the action manager index, add by that index and restore the active layer.
function addLayerTransToSelection( layerIndex ){
try{
var desc = new ActionDescriptor();
var ref = new ActionReference();
ref.putEnumerated( charIDToTypeID( "Chnl" ), charIDToTypeID( "Chnl" ), charIDToTypeID( "Trsp" ) );
ref.putEnumerated( charIDToTypeID("Lyr "), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
ref.putIndex(charIDToTypeID( "Lyr " ), layerIndex );
//ref.putName( charIDToTypeID( "Lyr " ), layerName );
desc.putReference( charIDToTypeID( "null" ), ref );
var ref1 = new ActionReference();
ref1.putProperty( charIDToTypeID( "Chnl" ), charIDToTypeID( "fsel" ) );
desc.putReference( charIDToTypeID( "T " ), ref1 );
executeAction( charIDToTypeID( "Add " ), desc, DialogModes.NO );
return true;
}catch(e){alert(e);}
return false;
}
var ref = new ActionReference();
ref.putEnumerated( charIDToTypeID("Lyr "), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
var index = executeActionGet(ref).getInteger( stringIDToTypeID( 'itemIndex' ) );
addLayerTransToSelection( index );
Find more inspiration, events, and resources on the new Adobe Community
Explore Now