Copy link to clipboard
Copied
Hi.
I'm trying to set the opacity and fillOpacity of all layers and groups to 100% (an later also store the previous values in an array and restore them when done).
This works fine for the artLayers but the layerSet object doesn't seem to have a fillOpacity property, yet I can set a fillOpacity value on a group manually.
So how do I set and retrieve the fillOpacity value of a group?
Copy link to clipboard
Copied
You can get/set a layerSet's fillOpacity with Action Manager.
function getActiveLayerFillOpacity(){
var ref = new ActionReference();
ref.putEnumerated( charIDToTypeID("Lyr "), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
return executeActionGet(ref).getInteger(stringIDToTypeID("fillOpacity"));
};
function setActiveLayerFillOpacity( opacity ) {
var desc = new ActionDescriptor();
var ref = new ActionReference();
ref.putEnumerated( charIDToTypeID('Lyr '), charIDToTypeID('Ordn'), charIDToTypeID('Trgt') );
desc.putReference( charIDToTypeID('null'), ref );
var layerDesc = new ActionDescriptor();
layerDesc.putUnitDouble( stringIDToTypeID('fillOpacity'), charIDToTypeID('#Prc'), opacity );
desc.putObject( charIDToTypeID('T '), charIDToTypeID('Lyr '), layerDesc );
executeAction( charIDToTypeID('setd'), desc, DialogModes.NO );
};
Copy link to clipboard
Copied
Thanks.
I wish there was a way to do all these things using the DOM, this Action Manager just seems so messy.
Copy link to clipboard
Copied
Ah, wait, setting still doesn't work on the fillOpacity of the group, only on an artLayer.
(Gettting "General Photoshop error... This functionality may not be available...) on the last line.
Copy link to clipboard
Copied
Sorry, I posted code from my code library without testing. Either Adobe has changed something or my code never worked.
It is strange that both scriptlistener and actions record setting a layerSet fillOpacity but both fail on playback.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now