Drop Shadows, script

Discussion of Photoshop Scripting, Photoshop Actions and Photoshop Automation in General

Moderators: Tom, Kukurykus

ylafont

Drop Shadows, script

Post by ylafont »

I was following a previous post (http://ps-scripts.com/bb/viewtopic.php?t=2207) on creating a drop shadow via scripting; however I have run into a few issues. First the code generate via script listener does not work; I have created several times without success (Code Listed below). I then preceded to create a predefined Layer Style and use it via the command ”ArtLayer.applyStyle("DropShadow"). I named the style DropShadow. However that command does not apply the Layer Style. I was able to use the command docRef.activeLayer.applyStyle ("DropShadow"), and although this applies the style, the style is not applied with the settings it was saved with.
I am doing something wrong and is there another method of making this work? Thank you in advance.


ScritpListener Code:
var idsetd = charIDToTypeID( "setd" );
var desc21 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
var ref11 = new ActionReference();
var idPrpr = charIDToTypeID( "Prpr" );
var idLefx = charIDToTypeID( "Lefx" );
ref11.putProperty( idPrpr, idLefx );
var idLyr = charIDToTypeID( "Lyr " );
var idOrdn = charIDToTypeID( "Ordn" );
var idTrgt = charIDToTypeID( "Trgt" );
ref11.putEnumerated( idLyr, idOrdn, idTrgt );
desc21.putReference( idnull, ref11 );
var idT = charIDToTypeID( "T " );
var desc22 = new ActionDescriptor();
var idgagl = charIDToTypeID( "gagl" );
var idAng = charIDToTypeID( "#Ang" );
desc22.putUnitDouble( idgagl, idAng, 117.000000 );
var idScl = charIDToTypeID( "Scl " );
var idPrc = charIDToTypeID( "#Prc" );
desc22.putUnitDouble( idScl, idPrc, 333.333333 );
var idDrSh = charIDToTypeID( "DrSh" );
var desc23 = new ActionDescriptor();
var idenab = charIDToTypeID( "enab" );
desc23.putBoolean( idenab, true );
var idMd = charIDToTypeID( "Md " );
var idBlnM = charIDToTypeID( "BlnM" );
var idMltp = charIDToTypeID( "Mltp" );
desc23.putEnumerated( idMd, idBlnM, idMltp );
var idClr = charIDToTypeID( "Clr " );
var desc24 = new ActionDescriptor();
var idRd = charIDToTypeID( "Rd " );
desc24.putDouble( idRd, 0.000000 );
var idGrn = charIDToTypeID( "Grn " );
desc24.putDouble( idGrn, 0.000000 );
var idBl = charIDToTypeID( "Bl " );
desc24.putDouble( idBl, 0.000000 );
var idRGBC = charIDToTypeID( "RGBC" );
desc23.putObject( idClr, idRGBC, desc24 );
var idOpct = charIDToTypeID( "Opct" );
var idPrc = charIDToTypeID( "#Prc" );
desc23.putUnitDouble( idOpct, idPrc, 75.000000 );
var iduglg = charIDToTypeID( "uglg" );
desc23.putBoolean( iduglg, true );
var idlagl = charIDToTypeID( "lagl" );
var idAng = charIDToTypeID( "#Ang" );
desc23.putUnitDouble( idlagl, idAng, 120.000000 );
var idDstn = charIDToTypeID( "Dstn" );
var idPxl = charIDToTypeID( "#Pxl" );
desc23.putUnitDouble( idDstn, idPxl, 17.000000 );
var idCkmt = charIDToTypeID( "Ckmt" );
var idPxl = charIDToTypeID( "#Pxl" );
desc23.putUnitDouble( idCkmt, idPxl, 9.000000 );
var idblur = charIDToTypeID( "blur" );
var idPxl = charIDToTypeID( "#Pxl" );
desc23.putUnitDouble( idblur, idPxl, 17.000000 );
var idNose = charIDToTypeID( "Nose" );
var idPrc = charIDToTypeID( "#Prc" );
desc23.putUnitDouble( idNose, idPrc, 0.000000 );
var idAntA = charIDToTypeID( "AntA" );
desc23.putBoolean( idAntA, false );
var idTrnS = charIDToTypeID( "TrnS" );
var desc25 = new ActionDescriptor();
var idNm = charIDToTypeID( "Nm " );
desc25.putString( idNm, """Linear""" );
var idShpC = charIDToTypeID( "ShpC" );
desc23.putObject( idTrnS, idShpC, desc25 );
var idlayerConceals = stringIDToTypeID( "layerConceals" );
desc23.putBoolean( idlayerConceals, true );
var idDrSh = charIDToTypeID( "DrSh" );
desc22.putObject( idDrSh, idDrSh, desc23 );
var idLefx = charIDToTypeID( "Lefx" );
desc21.putObject( idT, idLefx, desc22 );
executeAction( idsetd, desc21, DialogModes.NO );

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

Mike Hale

Drop Shadows, script

Post by Mike Hale »

I can think of several reason the scriptlistener code doesn't work.

1. The charIDToTypeIDs need four chars( pad with spaces if needed ). So check those, at least some are too short in the code you posted.
2. desc25.putString( idNm, """Linear""" ); should be desc25.putString( idNm, "Linear" ); for English versions of Photoshop.
3. The code works with the activeLayer. So it will not work if the activeLayer is the background layer or the layer is locked.

Yes, applyStyle() only works with a saved layer style and that style will use the same settings.
ylafont

Drop Shadows, script

Post by ylafont »

I think that did the trick! Excellent, thank you.