Change opacity parent of layer

Anyone, especially newbies, asking for help with Photoshop Scripting and Photoshop Automation - as opposed to those contributing to discussion about an aspect of Photoshop Scripting

Moderators: Tom, Kukurykus

stat

Change opacity parent of layer

Post by stat »

Help me please. I want to convert this code
Code: Select allif(app.activeDocument.activeLayer.parent.typename == "LayerSet")
   app.activeDocument.activeLayer.parent.opacity=75;

a strange language "ActionDescriptor-ActionReference"
I need to change the opacity "LayerSet".
I'm doing this:
Code: Select all  var desc1 = new ActionDescriptor();
    var ref1 = new ActionReference();
    ref1.putEnumerated(cTID('Lyr '), cTID('Ordn'), cTID('Trgt'));
    desc1.putReference(cTID('null'), ref1);
    var desc2 = new ActionDescriptor();
    desc2.putUnitDouble(cTID('Opct'), cTID('#Prc'), 75 );
    desc1.putObject(cTID('T   '), cTID('Lyr '), desc2);
    executeAction(cTID('setd'), desc1, dialogMode);
but it changes the opacity of the layer itself, and not the parent!

thanks in advance

Professional AI Audio Generation within Adobe Premiere Pro - Download Free Plugin here

Mike Hale

Change opacity parent of layer

Post by Mike Hale »

I am not sure what you are asking but if you want to convert the ActionManager code to a Photoshop Object Model version it would look like this.
Code: Select allapp.activeDocument.activeLayer.opacity=75;
Note that will set the opacity of the activeLayer. The ActionManager code doesn't check to see if the activeLayer is a layerSet as your first code does. But you can add the if statement if wanted. just remove the '.parent' part.