Add multiple layer effects by action manager
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)