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

Add multiple layer effects by action manager

Participant ,
Nov 10, 2021 Nov 10, 2021

Copy link to clipboard

Copied

I made two function, one for creating a stroke and one for creating an outerglow effect.

They work fine if you only need one effect, but when you need a stroke and outerglow effect, the previous effect is removed. I checked scriptlistener to see what happends when I manually apply a outerglow when it already has a stroke, and it seems like it also includes all stroke effect parameters...

Is there a way I can change my functions so they will add effects instead of replacing?

 

This is the code I'm using...

function initializeActionmanagerIDs(){
    
    PSClass = function() {};
    PSEnum = function() {};
    PSEvent = function() {};
    PSForm = function() {};
    PSKey = function() {};
    PSType = function() {};
    PSUnit = function() {};
    PSString = function() {};
    
    PSClass.Version = cTID('Vrsn');
    PSClass.Pixel = cTID('Pxel');
    PSClass.Offset = cTID('Ofst');
    PSClass.Channel = cTID('Chnl');
    PSClass.Mask = cTID('Msk ');
    //PSClass.MenuItem = cTID('Mn ');
    PSClass.AdjustmentLayer = cTID('AdjL');
    PSClass.Color = cTID('Clr ');
    PSClass.Curves = cTID('Crvs');
    PSClass.CurvesAdjustment = cTID('CrvA');
    //PSClass.PaintbrushTool = cTID('PbTl');
    PSClass.Point = cTID('Pnt ');
    PSClass.Document = cTID('Dcmn');
    PSClass.Layer = cTID('Lyr ');
    PSClass.LayerEffects = cTID('Lefx');
    PSClass.Property = cTID('Prpr');
    PSClass.RGBColor = cTID('RGBC');
    PSClass.ShapingCurve = cTID('ShpC');
    PSClass.Application = cTID('capp');
    PSClass.CurvePoint = cTID('CrPt');
    PSClass.OuterGlow = cTID('OrGl');
    
    PSEnum.Transparency = cTID('Trsp');
    PSEnum.MergedLayers = cTID('Mrg2');
    PSEnum.RevealAll = cTID('RvlA');
    PSEnum.QCSAverage = cTID('Qcsa');
    PSEnum.Bilinear = cTID('Blnr');
    PSEnum.NearestNeighbor = cTID('Nrst');
    PSEnum.Bicubic = cTID('Bcbc');
    //PSEnum.FitOnScreen = cTID('FtOn');
    PSEnum.None = cTID('None');
    PSEnum.Blue = cTID('Bl  ');
    PSEnum.Composite = cTID('Cmps');
    PSEnum.Green = cTID('Grn ');
    PSEnum.Red = cTID('Rd  ');
    PSEnum.Target = cTID('Trgt');
    PSEnum.All = cTID('Al  ');
    PSEnum.AntiAliasNone = cTID('Anno');
    //PSEnum.Center = cTID('Cntr');
    //PSEnum.Darken = cTID('Drkn');
    //PSEnum.First = cTID('Frst');
    //PSEnum.InnerBevel = cTID('InrB')
    //PSEnum.Multiply = cTID('Mltp');
    PSEnum.Normal = cTID('Nrml');
    //PSEnum.Outside = cTID('Otsd');
    //PSEnum.Screen = cTID('Scrn');
    PSEnum.SoftMatte = cTID('SfBL');
    //PSEnum.StampIn = cTID('In  ');
    //PSEnum.White = cTID('Wht ');
    PSEnum.Add = cTID('Add ');
    PSEnum.RevealSelection = cTID('RvlS');
    PSEnum.RGB = cTID('RGB ');
    PSEnum.Pattern = cTID('Ptrn');
    PSEnum.InsetFrame = cTID('InsF');
    PSEnum.SolidColor = cTID('SClr');
    PSEnum.Linked = cTID('Lnkd');
    PSEnum.Background = cTID('Bckg');
    
    PSEvent.FullySelected = cTID('fsel');
    PSEvent.CopyMerged = cTID('CpyM');
    PSEvent.Place = cTID('Plc ');
    PSEvent.FlattenImage = cTID('FltI');
    PSEvent.Intersect = cTID('Intr');
    PSEvent.ImageSize = cTID('ImgS');
    PSEvent.GaussianBlur = cTID('GsnB');
    PSEvent.MotionBlur = cTID('MtnB');
    PSEvent.Crop = cTID('Crop');
    PSEvent.Select = cTID('slct');
    PSEvent.Set = cTID('setd');
    PSEvent.Invert = cTID('Invr');
    //PSEvent.Exchange = cTID('Exch');
    PSEvent.Make = cTID('Mk  ');
    //PSEvent.Reset = cTID('Rset');
    //PSEvent.Contract = cTID('Cntc');
    PSEvent.Copy = cTID('copy');
    PSEvent.Duplicate = cTID('Dplc');
    PSEvent.Fill = cTID('Fl  ');
    PSEvent.Paste = cTID('past');
    //PSEvent.Stroke = cTID('Strk');
    PSEvent.Delete = cTID('Dlt ');
    PSEvent.Group = cTID('GrpL');
    
    PSForm.Identifier = cTID('Idnt');
    
    PSKey.UserMaskEnabled = cTID('UsrM');
    PSKey.At = cTID('At  ');
    PSKey.New = cTID('Nw  ');
    PSKey.FreeTransformCenterState = cTID('FTcs');
    PSKey.ClippingPath = cTID('ClPt');
    PSKey.PageNumber = cTID('PgNm');
    PSKey.As = cTID('As  ');
    PSKey.InterfacePaletteFill = cTID('IntP');
    PSKey.InterfaceIconFrameDimmed = cTID('Intr');
    PSKey.Angle = cTID('Angl');
    PSKey.Amount = cTID('Amnt');
    PSKey.Blur = cTID('blur');
    PSKey.HighlightMode = cTID('hglM');
    PSKey.Radius = cTID('Rds ');
    PSKey.ShadowMode = cTID('sdwM');
    PSKey.Threshold = cTID('Thsh');
    PSKey.Width = cTID('Wdth');
    PSKey.Height = cTID('Hght'); // Resize
    //PSKey.To = cTID('T ');
    PSKey.Adjustment = cTID('Adjs');
    //PSKey.Colors = cTID('Clrs');
    PSKey.Curve = cTID('Crv ');
    PSKey.Horizontal = cTID('Hrzn');
    PSKey.Type = cTID('Type');
    PSKey.Using = cTID('Usng');
    PSKey.Vertical = cTID('Vrtc');
    PSKey.AntiAlias = cTID('AntA');
    //PSKey.BevelDirection = cTID('bvlD');
    //PSKey.BevelEmboss = cTID('ebbl');
    //PSKey.BevelStyle = cTID('bvlS');
    //PSKey.BevelTechnique = cTID('bvlT');
    //PSKey.Blue = cTID('Bl  ');
    //PSKey.By = cTID('By  ');
    PSKey.ChokeMatte = cTID('Ckmt');
    //PSKey.Distance = cTID('Dstn');
    //PSKey.DropShadow = cTID('DrSh');
    PSKey.Enabled = cTID('enab');
    //PSKey.GlobalLightingAngle = cTID('gagl');
    //PSKey.Green = cTID('Grn ');
    //PSKey.HighlightColor = cTID('hglC');
    PSKey.HighlightOpacity = cTID('hglO');
    //PSKey.LocalLightingAltitude = cTID('Lald');
    //PSKey.LocalLightingAngle = cTID('lagl');
    //PSKey.LocalLightingAngle = cTID('lagl');
    //PSKey.Location = cTID('Lctn');
    PSKey.Mode = cTID('Md  ');
    PSKey.Name = cTID('Nm  ');
    PSKey.Noise = cTID('Nose');
    PSKey.DocumentID = cTID('DocI');
    PSKey.Opacity = cTID('Opct');
    //PSKey.Relative = cTID('Rltv');
    PSKey.Scale = cTID('Scl ');
    //PSKey.ShadowColor = cTID('sdwC');
    //PSKey.ShadowOpacity = cTID('sdwO');
    //PSKey.Softness = cTID('Sftn');
    //PSKey.StrengthRatio = cTID('srgR'); 
    PSKey.TransparencyShape = cTID('TrnS');
    //PSKey.UseGlobalAngle = cTID('uglg');
    PSKey.To = cTID('T   ');
    PSKey.LayerID = cTID('LyrI');
    PSKey.MakeVisible = cTID('MkVs');
    PSKey.Apply = cTID('Aply');
    PSKey.FrameFX = cTID('FrFX');
    PSKey.Style = cTID('Styl');
    PSKey.PaintType = cTID('PntT');
    PSKey.SizeKey = cTID('Sz  ');
    //PSKey.LinkEnable = cTID('SlnkE');
    PSKey.Append = cTID('Appe');
    PSKey.GlowTechnique = cTID('GlwT');
    PSKey.ShadingNoise = cTID('ShdN');
    
    PSString.bicubicSharper = sTID('bicubicSharper');
    PSString.bicubicSmoother = sTID('bicubicSmoother');
    PSString.deepUpscale = sTID('deepUpscale');
    PSString.preserveDetailsUpscale = sTID('preserveDetailsUpscale');
    PSString.automaticBestFit = sTID('automaticInterpolation');
    PSString.blurType = sTID('blurType');
    PSString.lensBlur = sTID('lensBlur');
    PSString.moreAccurate = sTID('moreAccurate');
    PSString.preset = sTID('preset');
    PSString.smartSharpen = sTID('smartSharpen');
    PSString.Null = sTID('null');
    //PSString.selection = sTID('selection');
    PSString.presetKind = sTID('presetKind');
    PSString.presetKindCustom = sTID('presetKindCustom');
    PSString.presetKindDefault = sTID('presetKindDefault');
    PSString.presetKindType = sTID('presetKindType');
    PSString.AntialiasGloss = sTID('antialiasGloss');
    PSString.canvasExtensionColorType = sTID('canvasExtensionColorType');
    PSString.layerConceals = sTID('layerConceals');
    PSString.useShape = sTID('useShape');
    PSString.useTexture = sTID('useTexture');
    PSString.pdfSelection = sTID('pdfSelection');
    PSString.page = sTID('page');
    PSString.cropTo = sTID('cropTo');
    PSString.boundingBox = sTID('boundingBox');
    PSString.suppressWarnings = sTID('suppressWarnings');
    PSString.PDFGenericFormat = sTID('PDFGenericFormat');
    PSString.selection = sTID('selection');
    PSString.selectAllLayers = sTID('selectAllLayers');
    PSString.hasUserMask = sTID('hasUserMask');
    PSString.hasVectorMask = sTID('hasVectorMask');
    PSString.black = sTID('black');
    PSString.white = sTID('white');
    PSString.opacity = sTID('opacity');
    PSString.percentUnit = sTID('percentUnit');
    PSString.mode = sTID('mode');
    PSString.blendMode = sTID('blendMode');
    PSString.normal = sTID('normal');
    PSString.fill = sTID('fill');
    PSString.contentLayer = sTID('contentLayer');
    PSString.patternLayer = sTID('patternLayer');
    PSString.disableLayerStyle = sTID('disableLayerStyle');
    PSString.showInDialog = sTID('showInDialog');
    PSString.present = sTID('present');
    PSString.overprint = sTID('overprint');
    PSString.layerEffects = sTID('layerEffects');
    PSString.name = sTID('name');
    PSString.InputRange = sTID('Inpr');
    
    PSString.linked = sTID('linked');
    PSString.linkedLayerIDs = sTID('linkedLayerIDs');
    PSString.filterMaskLinked = sTID('filterMaskLinked');
    PSString.layerSetFromLinkedEvent = sTID('layerSetFromLinkedEvent');
    PSString.selectLinkedLayers = sTID('selectLinkedLayers');
    PSString.toLinked = sTID('toLinked');
    PSString.link = sTID('link');
    PSString.linkSelectedLayers = sTID('linkSelectedLayers');
    PSString.enableLayerLink = sTID('enableLayerLink');
    PSString.disableLayerLink = sTID('disableLayerLink');
    PSString.unlink = sTID('unlink');
    PSString.unlinkSelectedLayers = sTID('unlinkSelectedLayers');
    PSString.group = sTID('group');
    PSString.layerGroup = sTID('layerGroup');
    PSString.layerSection = sTID('layerSection');
    PSString.layerGroupType = sTID('layerGroupType');
    PSString.layerSectionType = sTID('layerSectionType');
    PSString.layerGroupFromLinkedEvent = sTID('layerGroupFromLinkedEvent');
    PSString.layerSetFromLinkedEvent = sTID('layerSetFromLinkedEvent');
    PSString.layerGroupFromSelectedEvent = sTID('layerGroupFromSelectedEvent');
    PSString.layerSetFromSelectedEvent = sTID('layerSetFromSelectedEvent');
    PSString.layerGroupExpanded = sTID('layerGroupExpanded');
    PSString.layerSectionExpanded = sTID('layerSectionExpanded');
    PSString.groupLayersEvent = sTID('groupLayersEvent');
    PSString.ungroupLayersEvent = sTID('ungroupLayersEvent');
    PSString.sceneGroup = sTID('sceneGroup');
    PSString.sceneSection = sTID('sceneSection');
    PSString.ungroup = sTID('ungroup');
    PSString.presetManager = sTID('presetManager');
    PSString.groupEnd = sTID('groupEnd');
    PSString.hierarchy = sTID('hierarchy');
    PSString.solidColorLayer = sTID('solidColorLayer');
    PSString.fillOpacity = sTID('fillOpacity');

    PSUnit.Percent = cTID('#Prc');
    PSUnit.Pixels = cTID('#Pxl');
    //PSUnit.Distance = cTID('#Rlt');
    //PSUnit.Angle = cTID('#Ang');
    
    PSType.QuadCenterState = cTID('QCSt');
    PSType.Interpolation = cTID('Intp');
    //PSType.MenuItem = cTID('MnIt');
    PSType.Ordinal = cTID('Ordn');
    PSType.AntiAlias = cTID('Annt');
    PSType.BlendMode = cTID('BlnM');
    PSType.FillContents = cTID('FlCn');
    //PSType.HorizontalLocation = cTID('HrzL');
    //PSType.BevelEmbossStampStyle = cTID('BESs');
    //PSType.BevelEmbossStyle = cTID('BESl');
    //PSType.BlendMode = cTID('BlnM')
    //PSType.StrokeLocation = cTID('StrL');
    //PSType.VerticalLocation = cTID('VrtL');
    PSType.FrameStyle = cTID('FStl');
    PSType.FrameFill = cTID('FrFl');
    PSType.MatteTechnique = cTID('BETE');
    }
initializeActionmanagerIDs();
function actionManagerApplyStroke(scalePercentage, enabled, present, showInDialog, opacity, size, red, green, blue, overprint){

    var d1 = new ActionDescriptor();
    var d2 = new ActionDescriptor();
    var d3 = new ActionDescriptor();
    var d4 = new ActionDescriptor();
    var r1 = new ActionReference();
    
    r1.putProperty(PSClass.Property, PSClass.LayerEffects);
    r1.putEnumerated(PSClass.Layer, PSType.Ordinal, PSEnum.Target);
    d1.putReference(PSString.Null, r1);
    d2.putUnitDouble(PSKey.Scale, PSUnit.Percent, scalePercentage);
    d3.putBoolean(PSKey.Enabled, enabled);
    d3.putBoolean(PSString.present, present);
    d3.putBoolean(PSString.showInDialog, showInDialog);
    d3.putEnumerated(PSKey.Style, PSType.FrameStyle, PSEnum.InsetFrame);
    d3.putEnumerated(PSKey.PaintType, PSType.FrameFill, PSEnum.SolidColor);
    d3.putEnumerated(PSKey.Mode, PSType.BlendMode, PSEnum.Normal);
    d3.putUnitDouble(PSKey.Opacity, PSUnit.Percent, opacity);
    d3.putUnitDouble(PSKey.SizeKey, PSUnit.Pixels, size);
    d4.putDouble(PSEnum.Red, red);
    d4.putDouble(PSEnum.Green, green);
    d4.putDouble(PSEnum.Blue, blue);
    d3.putObject(PSClass.Color, PSClass.RGBColor, d4);
    d3.putBoolean(PSString.overprint, overprint);
    d2.putObject(PSKey.FrameFX, PSKey.FrameFX, d3);
    d1.putObject(PSKey.To, PSClass.LayerEffects, d2);
    
    executeAction(PSEvent.Set, d1, DialogModes.NO );
    }

function actionManagerApplyOuterGlow(scalePercentage, enabled, present, showInDialog, red, green, blue, opacity, chokeMattePixels, size, noisePercentage, shadingNoisePercentage, antiAlias, name, curvePoint01Horizontal, curvePoint01Vertical, curvePoint02Horizontal, curvePoint02Vertical, inputRangePercentage){
 
    var d1 = new ActionDescriptor();
    var d2 = new ActionDescriptor();
    var d3 = new ActionDescriptor();
    var d4 = new ActionDescriptor();
    var d5 = new ActionDescriptor();
    var d6 = new ActionDescriptor();
    var d7 = new ActionDescriptor();
    var r1 = new ActionReference();
    var l1 = new ActionList();

    r1.putProperty(PSClass.Property, PSClass.LayerEffects);
    r1.putEnumerated(PSClass.Layer, PSType.Ordinal, PSEnum.Target);
    d1.putReference(PSString.Null, r1);
    d2.putUnitDouble(PSKey.Scale, PSUnit.Percent, scalePercentage);
    d3.putBoolean(PSKey.Enabled, enabled);
    d3.putBoolean(PSString.present, present);
    d3.putBoolean(PSString.showInDialog, showInDialog);
    d3.putEnumerated(PSKey.Mode, PSType.BlendMode, PSEnum.Normal);
    
    d4.putDouble(PSEnum.Red, red);
    d4.putDouble(PSEnum.Green, green);
    d4.putDouble(PSEnum.Blue, blue);    
    d3.putObject(PSClass.Color, PSClass.RGBColor, d4 );
    
    d3.putUnitDouble(PSKey.Opacity, PSUnit.Percent, opacity);
    d3.putEnumerated(PSKey.GlowTechnique, PSType.MatteTechnique, PSEnum.SoftMatte);
    d3.putUnitDouble(PSKey.ChokeMatte, PSUnit.Pixels, chokeMattePixels);
    d3.putUnitDouble(PSKey.Blur, PSUnit.Pixels, size);
    d3.putUnitDouble(PSKey.Noise, PSUnit.Percent, noisePercentage);
    d3.putUnitDouble(PSKey.ShadingNoise, PSUnit.Percent, shadingNoisePercentage); 
    d3.putBoolean(PSKey.AntiAlias, antiAlias);   
    d5.putString(PSKey.Name, name);
    
    d6.putDouble(PSKey.Horizontal, curvePoint01Horizontal);
    d6.putDouble(PSKey.Vertical, curvePoint01Vertical);
    l1.putObject(PSClass.CurvePoint, d6);
    
    d7.putDouble(PSKey.Horizontal, curvePoint02Horizontal);
    d7.putDouble(PSKey.Vertical, curvePoint02Vertical);            
    l1.putObject(PSClass.CurvePoint, d7);
    
    d5.putList(PSKey.Curve, l1);
    d3.putObject(PSKey.TransparencyShape, PSClass.ShapingCurve, d5 );
    d3.putUnitDouble(PSString.InputRange, PSUnit.Percent, inputRangePercentage);
    d2.putObject(PSClass.OuterGlow, PSClass.OuterGlow, d3 );
    d1.putObject(PSKey.To, PSClass.LayerEffects, d2 );
    
    executeAction(PSEvent.Set, d1, DialogModes.NO );
    }

actionManagerApplyOuterGlow(416, true, true, true, 0, 0, 0, 35, 0, 7, 0, 0, false, "Default", 0, 0, 255, 255, 50)
actionManagerApplyStroke(100, true, true, true, 100, 2, 0, 0, 0, true)

 

TOPICS
Actions and scripting

Views

527

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 , Nov 11, 2021 Nov 11, 2021

If you want to add an effect, and not completely update all the effects of the layer, then before applying it you need to save the current settings of the effects to a variable and then use this descriptor to add new effects instead of "new ActionDescriptor ()"

 

cTID = charIDToTypeID;
sTID = stringIDToTypeID;
function initializeActionmanagerIDs() {
    PSClass = function () { };
    PSEnum = function () { };
    PSEvent = function () { };
    PSForm = function () { };
    PSKey = function () { 
...

Votes

Translate

Translate
Adobe
People's Champ ,
Nov 11, 2021 Nov 11, 2021

Copy link to clipboard

Copied

Advice

 

To add an arbitrary effect to a layer with the existing effects, create a new empty layer, apply the desired effect to it, drag this effect onto the layer you need. Delete the empty temporary layer. Examine the code how to move the layer effect to the desired layer, which will generate the scriptlistener.

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
Community Expert ,
Nov 11, 2021 Nov 11, 2021

Copy link to clipboard

Copied

@r-bin â€“ I like it, I think that the new temp layer is the key...

 

So, something like this? Of note, an existing effect/style in the destination layer of the same kind as the source will not be replaced (so only "new" style kinds will be added).

 

 

// Create a new temp layer and apply the layer style
/* add your code */

// Move the layer style from source to target layer
var idmove = stringIDToTypeID( "move" );
    var desc609 = new ActionDescriptor();
    var idnull = stringIDToTypeID( "null" );
        var ref156 = new ActionReference();
        var idlayerEffects = stringIDToTypeID( "layerEffects" );
        ref156.putClass( idlayerEffects );
        var idlayer = stringIDToTypeID( "layer" );
        ref156.putName( idlayer, "Source" );
    desc609.putReference( idnull, ref156 );
    var idto = stringIDToTypeID( "to" );
        var ref157 = new ActionReference();
        var idlayer = stringIDToTypeID( "layer" );
        // Target layer
        ref157.putIndex( idlayer, 1 );
    desc609.putReference( idto, ref157 );
executeAction( idmove, desc609, DialogModes.NO );

// Delete the temp layer
/* add your code */

 

 

////////// ALTERNATIVE //////////

 

 

// Create a new temp layer and apply the layer style
/* add your code */

// Copy the layer style from active temp layer
var idcopyEffects = stringIDToTypeID( "copyEffects" );
executeAction(idcopyEffects, undefined, DialogModes.NO);

// Delete the temp layer
/* add your code */

// Select the destination layer...
/* add your code */

// Option + Paste the layer style
var idpasteEffects = stringIDToTypeID( "pasteEffects" );
    var desc408 = new ActionDescriptor();
    var idallowPasteFXOnLayerSet = stringIDToTypeID( "allowPasteFXOnLayerSet" );
    desc408.putBoolean( idallowPasteFXOnLayerSet, true );
executeAction(idpasteEffects, desc408, DialogModes.NO);

 

Curious minds need to know... There is a different result when using the GUI when using the paste layer style command with and without the OPT/ALT key depressed, however, scriptlistener appears to record them both the same?

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
LEGEND ,
Nov 12, 2021 Nov 12, 2021

Copy link to clipboard

Copied

In both cases a generated code updates a style, so unpressed ALT for new style isn't recorded.

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
Community Expert ,
Nov 12, 2021 Nov 12, 2021

Copy link to clipboard

Copied

Hmm, OK, I was just expecting a boolean or different code or something else – rather than the same code being recorded for two totally different operations!

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
People's Champ ,
Nov 12, 2021 Nov 12, 2021

Copy link to clipboard

Copied

quote

Hmm, OK, I was just expecting a boolean or different code or something else – rather than the same code being recorded for two totally different operations!


By @Stephen_A_Marsh

 

It looks like a bug.

But then the solution is very simple, without the participation of a tmp layer.

 

1. try to copy layer style (if exists)

2. clear layer style

3. apply new FX

4. try to paste layer style (via script or action).

 

 

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
LEGEND ,
Nov 13, 2021 Nov 13, 2021

Copy link to clipboard

Copied

LATEST

I don't say it should be like it. Maybe if that was not Alt key, but Shift, or Ctrl (we know here don't work) that often is used to replay once used menu item it'd be recorded to the log file?

 

I mean Alt is used to use previously used settings, so the event signal seems to be jammed 😞

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
Guide ,
Nov 11, 2021 Nov 11, 2021

Copy link to clipboard

Copied

If you want to add an effect, and not completely update all the effects of the layer, then before applying it you need to save the current settings of the effects to a variable and then use this descriptor to add new effects instead of "new ActionDescriptor ()"

 

cTID = charIDToTypeID;
sTID = stringIDToTypeID;
function initializeActionmanagerIDs() {
    PSClass = function () { };
    PSEnum = function () { };
    PSEvent = function () { };
    PSForm = function () { };
    PSKey = function () { };
    PSType = function () { };
    PSUnit = function () { };
    PSString = function () { };
    PSClass.Version = cTID('Vrsn');
    PSClass.Pixel = cTID('Pxel');
    PSClass.Offset = cTID('Ofst');
    PSClass.Channel = cTID('Chnl');
    PSClass.Mask = cTID('Msk ');
    PSClass.AdjustmentLayer = cTID('AdjL');
    PSClass.Color = cTID('Clr ');
    PSClass.Curves = cTID('Crvs');
    PSClass.CurvesAdjustment = cTID('CrvA');
    PSClass.Point = cTID('Pnt ');
    PSClass.Document = cTID('Dcmn');
    PSClass.Layer = cTID('Lyr ');
    PSClass.LayerEffects = cTID('Lefx');
    PSClass.Property = cTID('Prpr');
    PSClass.RGBColor = cTID('RGBC');
    PSClass.ShapingCurve = cTID('ShpC');
    PSClass.Application = cTID('capp');
    PSClass.CurvePoint = cTID('CrPt');
    PSClass.OuterGlow = cTID('OrGl');
    PSEnum.Transparency = cTID('Trsp');
    PSEnum.MergedLayers = cTID('Mrg2');
    PSEnum.RevealAll = cTID('RvlA');
    PSEnum.QCSAverage = cTID('Qcsa');
    PSEnum.Bilinear = cTID('Blnr');
    PSEnum.NearestNeighbor = cTID('Nrst');
    PSEnum.Bicubic = cTID('Bcbc');
    PSEnum.None = cTID('None');
    PSEnum.Blue = cTID('Bl  ');
    PSEnum.Composite = cTID('Cmps');
    PSEnum.Green = cTID('Grn ');
    PSEnum.Red = cTID('Rd  ');
    PSEnum.Target = cTID('Trgt');
    PSEnum.All = cTID('Al  ');
    PSEnum.AntiAliasNone = cTID('Anno');
    PSEnum.Normal = cTID('Nrml');
    PSEnum.SoftMatte = cTID('SfBL');
    PSEnum.Add = cTID('Add ');
    PSEnum.RevealSelection = cTID('RvlS');
    PSEnum.RGB = cTID('RGB ');
    PSEnum.Pattern = cTID('Ptrn');
    PSEnum.InsetFrame = cTID('InsF');
    PSEnum.SolidColor = cTID('SClr');
    PSEnum.Linked = cTID('Lnkd');
    PSEnum.Background = cTID('Bckg');
    PSEvent.FullySelected = cTID('fsel');
    PSEvent.CopyMerged = cTID('CpyM');
    PSEvent.Place = cTID('Plc ');
    PSEvent.FlattenImage = cTID('FltI');
    PSEvent.Intersect = cTID('Intr');
    PSEvent.ImageSize = cTID('ImgS');
    PSEvent.GaussianBlur = cTID('GsnB');
    PSEvent.MotionBlur = cTID('MtnB');
    PSEvent.Crop = cTID('Crop');
    PSEvent.Select = cTID('slct');
    PSEvent.Set = cTID('setd');
    PSEvent.Invert = cTID('Invr');
    PSEvent.Make = cTID('Mk  ');
    PSEvent.Copy = cTID('copy');
    PSEvent.Duplicate = cTID('Dplc');
    PSEvent.Fill = cTID('Fl  ');
    PSEvent.Paste = cTID('past');
    PSEvent.Delete = cTID('Dlt ');
    PSEvent.Group = cTID('GrpL');
    PSForm.Identifier = cTID('Idnt');
    PSKey.UserMaskEnabled = cTID('UsrM');
    PSKey.At = cTID('At  ');
    PSKey.New = cTID('Nw  ');
    PSKey.FreeTransformCenterState = cTID('FTcs');
    PSKey.ClippingPath = cTID('ClPt');
    PSKey.PageNumber = cTID('PgNm');
    PSKey.As = cTID('As  ');
    PSKey.InterfacePaletteFill = cTID('IntP');
    PSKey.InterfaceIconFrameDimmed = cTID('Intr');
    PSKey.Angle = cTID('Angl');
    PSKey.Amount = cTID('Amnt');
    PSKey.Blur = cTID('blur');
    PSKey.HighlightMode = cTID('hglM');
    PSKey.Radius = cTID('Rds ');
    PSKey.ShadowMode = cTID('sdwM');
    PSKey.Threshold = cTID('Thsh');
    PSKey.Width = cTID('Wdth');
    PSKey.Height = cTID('Hght'); 
    PSKey.Adjustment = cTID('Adjs');
    PSKey.Curve = cTID('Crv ');
    PSKey.Horizontal = cTID('Hrzn');
    PSKey.Type = cTID('Type');
    PSKey.Using = cTID('Usng');
    PSKey.Vertical = cTID('Vrtc');
    PSKey.AntiAlias = cTID('AntA');
    PSKey.ChokeMatte = cTID('Ckmt');
    PSKey.Enabled = cTID('enab');
    PSKey.HighlightOpacity = cTID('hglO');
    PSKey.Mode = cTID('Md  ');
    PSKey.Name = cTID('Nm  ');
    PSKey.Noise = cTID('Nose');
    PSKey.DocumentID = cTID('DocI');
    PSKey.Opacity = cTID('Opct');
    PSKey.Scale = cTID('Scl ');
    PSKey.TransparencyShape = cTID('TrnS');
    PSKey.To = cTID('T   ');
    PSKey.LayerID = cTID('LyrI');
    PSKey.MakeVisible = cTID('MkVs');
    PSKey.Apply = cTID('Aply');
    PSKey.FrameFX = cTID('FrFX');
    PSKey.Style = cTID('Styl');
    PSKey.PaintType = cTID('PntT');
    PSKey.SizeKey = cTID('Sz  ');
    PSKey.Append = cTID('Appe');
    PSKey.GlowTechnique = cTID('GlwT');
    PSKey.ShadingNoise = cTID('ShdN');
    PSString.bicubicSharper = sTID('bicubicSharper');
    PSString.bicubicSmoother = sTID('bicubicSmoother');
    PSString.deepUpscale = sTID('deepUpscale');
    PSString.preserveDetailsUpscale = sTID('preserveDetailsUpscale');
    PSString.automaticBestFit = sTID('automaticInterpolation');
    PSString.blurType = sTID('blurType');
    PSString.lensBlur = sTID('lensBlur');
    PSString.moreAccurate = sTID('moreAccurate');
    PSString.preset = sTID('preset');
    PSString.smartSharpen = sTID('smartSharpen');
    PSString.Null = sTID('null');
    PSString.presetKind = sTID('presetKind');
    PSString.presetKindCustom = sTID('presetKindCustom');
    PSString.presetKindDefault = sTID('presetKindDefault');
    PSString.presetKindType = sTID('presetKindType');
    PSString.AntialiasGloss = sTID('antialiasGloss');
    PSString.canvasExtensionColorType = sTID('canvasExtensionColorType');
    PSString.layerConceals = sTID('layerConceals');
    PSString.useShape = sTID('useShape');
    PSString.useTexture = sTID('useTexture');
    PSString.pdfSelection = sTID('pdfSelection');
    PSString.page = sTID('page');
    PSString.cropTo = sTID('cropTo');
    PSString.boundingBox = sTID('boundingBox');
    PSString.suppressWarnings = sTID('suppressWarnings');
    PSString.PDFGenericFormat = sTID('PDFGenericFormat');
    PSString.selection = sTID('selection');
    PSString.selectAllLayers = sTID('selectAllLayers');
    PSString.hasUserMask = sTID('hasUserMask');
    PSString.hasVectorMask = sTID('hasVectorMask');
    PSString.black = sTID('black');
    PSString.white = sTID('white');
    PSString.opacity = sTID('opacity');
    PSString.percentUnit = sTID('percentUnit');
    PSString.mode = sTID('mode');
    PSString.blendMode = sTID('blendMode');
    PSString.normal = sTID('normal');
    PSString.fill = sTID('fill');
    PSString.contentLayer = sTID('contentLayer');
    PSString.patternLayer = sTID('patternLayer');
    PSString.disableLayerStyle = sTID('disableLayerStyle');
    PSString.showInDialog = sTID('showInDialog');
    PSString.present = sTID('present');
    PSString.overprint = sTID('overprint');
    PSString.layerEffects = sTID('layerEffects');
    PSString.name = sTID('name');
    PSString.InputRange = sTID('Inpr');
    PSString.linked = sTID('linked');
    PSString.linkedLayerIDs = sTID('linkedLayerIDs');
    PSString.filterMaskLinked = sTID('filterMaskLinked');
    PSString.layerSetFromLinkedEvent = sTID('layerSetFromLinkedEvent');
    PSString.selectLinkedLayers = sTID('selectLinkedLayers');
    PSString.toLinked = sTID('toLinked');
    PSString.link = sTID('link');
    PSString.linkSelectedLayers = sTID('linkSelectedLayers');
    PSString.enableLayerLink = sTID('enableLayerLink');
    PSString.disableLayerLink = sTID('disableLayerLink');
    PSString.unlink = sTID('unlink');
    PSString.unlinkSelectedLayers = sTID('unlinkSelectedLayers');
    PSString.group = sTID('group');
    PSString.layerGroup = sTID('layerGroup');
    PSString.layerSection = sTID('layerSection');
    PSString.layerGroupType = sTID('layerGroupType');
    PSString.layerSectionType = sTID('layerSectionType');
    PSString.layerGroupFromLinkedEvent = sTID('layerGroupFromLinkedEvent');
    PSString.layerSetFromLinkedEvent = sTID('layerSetFromLinkedEvent');
    PSString.layerGroupFromSelectedEvent = sTID('layerGroupFromSelectedEvent');
    PSString.layerSetFromSelectedEvent = sTID('layerSetFromSelectedEvent');
    PSString.layerGroupExpanded = sTID('layerGroupExpanded');
    PSString.layerSectionExpanded = sTID('layerSectionExpanded');
    PSString.groupLayersEvent = sTID('groupLayersEvent');
    PSString.ungroupLayersEvent = sTID('ungroupLayersEvent');
    PSString.sceneGroup = sTID('sceneGroup');
    PSString.sceneSection = sTID('sceneSection');
    PSString.ungroup = sTID('ungroup');
    PSString.presetManager = sTID('presetManager');
    PSString.groupEnd = sTID('groupEnd');
    PSString.hierarchy = sTID('hierarchy');
    PSString.solidColorLayer = sTID('solidColorLayer');
    PSString.fillOpacity = sTID('fillOpacity');
    PSUnit.Percent = cTID('#Prc');
    PSUnit.Pixels = cTID('#Pxl');
    PSType.QuadCenterState = cTID('QCSt');
    PSType.Interpolation = cTID('Intp');
    PSType.Ordinal = cTID('Ordn');
    PSType.AntiAlias = cTID('Annt');
    PSType.BlendMode = cTID('BlnM');
    PSType.FillContents = cTID('FlCn');
    PSType.FrameStyle = cTID('FStl');
    PSType.FrameFill = cTID('FrFl');
    PSType.MatteTechnique = cTID('BETE');
}
initializeActionmanagerIDs();
function actionManagerApplyStroke(useCurrentFX, scalePercentage, enabled, present, showInDialog, opacity, size, red, green, blue, overprint) {
    if (useCurrentFX) {
        (r = new ActionReference()).putProperty(PSClass.Property, PSClass.LayerEffects);
        r.putEnumerated(PSClass.Layer, PSType.Ordinal, PSEnum.Target);
        var d2 = executeActionGet(r).hasKey(PSClass.LayerEffects) ? executeActionGet(r).getObjectValue(PSClass.LayerEffects) : new ActionDescriptor();
        if (d2.hasKey(k = sTID('frameFXMulti'))) d2.erase(k);
    } else {
        var d2 = new ActionDescriptor();
    }
    var d1 = new ActionDescriptor();
    var d3 = new ActionDescriptor();
    var d4 = new ActionDescriptor();
    var r1 = new ActionReference();
    r1.putProperty(PSClass.Property, PSClass.LayerEffects);
    r1.putEnumerated(PSClass.Layer, PSType.Ordinal, PSEnum.Target);
    d1.putReference(PSString.Null, r1);
    d2.putUnitDouble(PSKey.Scale, PSUnit.Percent, scalePercentage);
    d3.putBoolean(PSKey.Enabled, enabled);
    d3.putBoolean(PSString.present, present);
    d3.putBoolean(PSString.showInDialog, showInDialog);
    d3.putEnumerated(PSKey.Style, PSType.FrameStyle, PSEnum.InsetFrame);
    d3.putEnumerated(PSKey.PaintType, PSType.FrameFill, PSEnum.SolidColor);
    d3.putEnumerated(PSKey.Mode, PSType.BlendMode, PSEnum.Normal);
    d3.putUnitDouble(PSKey.Opacity, PSUnit.Percent, opacity);
    d3.putUnitDouble(PSKey.SizeKey, PSUnit.Pixels, size);
    d4.putDouble(PSEnum.Red, red);
    d4.putDouble(PSEnum.Green, green);
    d4.putDouble(PSEnum.Blue, blue);
    d3.putObject(PSClass.Color, PSClass.RGBColor, d4);
    d3.putBoolean(PSString.overprint, overprint);
    d2.putObject(PSKey.FrameFX, PSKey.FrameFX, d3);
    d1.putObject(PSKey.To, PSClass.LayerEffects, d2);
    executeAction(PSEvent.Set, d1, DialogModes.NO);
}
function actionManagerApplyOuterGlow(useCurrentFX, scalePercentage, enabled, present, showInDialog, red, green, blue, opacity, chokeMattePixels, size, noisePercentage, shadingNoisePercentage, antiAlias, name, curvePoint01Horizontal, curvePoint01Vertical, curvePoint02Horizontal, curvePoint02Vertical, inputRangePercentage) {
    if (useCurrentFX) {
        (r = new ActionReference()).putProperty(PSClass.Property, PSClass.LayerEffects);
        r.putEnumerated(PSClass.Layer, PSType.Ordinal, PSEnum.Target);
        var d2 = executeActionGet(r).hasKey(PSClass.LayerEffects) ? executeActionGet(r).getObjectValue(PSClass.LayerEffects) : new ActionDescriptor();
    } else {
        var d2 = new ActionDescriptor();
    }
    var d1 = new ActionDescriptor();
    var d3 = new ActionDescriptor();
    var d4 = new ActionDescriptor();
    var d5 = new ActionDescriptor();
    var d6 = new ActionDescriptor();
    var d7 = new ActionDescriptor();
    var r1 = new ActionReference();
    var l1 = new ActionList();
    r1.putProperty(PSClass.Property, PSClass.LayerEffects);
    r1.putEnumerated(PSClass.Layer, PSType.Ordinal, PSEnum.Target);
    d1.putReference(PSString.Null, r1);
    d2.putUnitDouble(PSKey.Scale, PSUnit.Percent, scalePercentage);
    d3.putBoolean(PSKey.Enabled, enabled);
    d3.putBoolean(PSString.present, present);
    d3.putBoolean(PSString.showInDialog, showInDialog);
    d3.putEnumerated(PSKey.Mode, PSType.BlendMode, PSEnum.Normal);
    d4.putDouble(PSEnum.Red, red);
    d4.putDouble(PSEnum.Green, green);
    d4.putDouble(PSEnum.Blue, blue);
    d3.putObject(PSClass.Color, PSClass.RGBColor, d4);
    d3.putUnitDouble(PSKey.Opacity, PSUnit.Percent, opacity);
    d3.putEnumerated(PSKey.GlowTechnique, PSType.MatteTechnique, PSEnum.SoftMatte);
    d3.putUnitDouble(PSKey.ChokeMatte, PSUnit.Pixels, chokeMattePixels);
    d3.putUnitDouble(PSKey.Blur, PSUnit.Pixels, size);
    d3.putUnitDouble(PSKey.Noise, PSUnit.Percent, noisePercentage);
    d3.putUnitDouble(PSKey.ShadingNoise, PSUnit.Percent, shadingNoisePercentage);
    d3.putBoolean(PSKey.AntiAlias, antiAlias);
    d5.putString(PSKey.Name, name);
    d6.putDouble(PSKey.Horizontal, curvePoint01Horizontal);
    d6.putDouble(PSKey.Vertical, curvePoint01Vertical);
    l1.putObject(PSClass.CurvePoint, d6);
    d7.putDouble(PSKey.Horizontal, curvePoint02Horizontal);
    d7.putDouble(PSKey.Vertical, curvePoint02Vertical);
    l1.putObject(PSClass.CurvePoint, d7);
    d5.putList(PSKey.Curve, l1);
    d3.putObject(PSKey.TransparencyShape, PSClass.ShapingCurve, d5);
    d3.putUnitDouble(PSString.InputRange, PSUnit.Percent, inputRangePercentage);
    d2.putObject(PSClass.OuterGlow, PSClass.OuterGlow, d3);
    d1.putObject(PSKey.To, PSClass.LayerEffects, d2);
    executeAction(PSEvent.Set, d1, DialogModes.NO);
}
actionManagerApplyOuterGlow(true, 416, true, true, true, 0, 0, 0, 35, 0, 7, 0, 0, false, "Default", 0, 0, 255, 255, 50)
actionManagerApplyStroke(true, 100, true, true, true, 100, 2, 0, 0, 0, true)

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
Participant ,
Nov 13, 2021 Nov 13, 2021

Copy link to clipboard

Copied

Thanks for posible solutions, I will test it all out soon, and report my results

 

 

Many thanks to everyone! Great solution and no need to create a new temp layer to transfer the effects.

Works great, I could not have come up with this code by myself, learned something today!

I hope many people also find this usefull, I could not find a similair function.

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