Copy link to clipboard
Copied
apply layer style layer1 using "Sunset Sky (Text)"
The above statement works for me in Photoshop
In the same way, Is there way that I can
apply layer style art layer using "Bevel and Emboss"
i.e., Layer--> Layer Style -->Bevel and Emboss-->Style(set to Outer Bevel)
Copy link to clipboard
Copied
Either create a named preset style that does what you want or use Scripting Listener code. There is no JS DOM for constructing styles.
-X
Copy link to clipboard
Copied
Thanks, what is this Scripting Listener Code
Copy link to clipboard
Copied
There is a plug-in called "ScriptingListener.plugin" (It should be found in the "Scripting Guide/Utilities" directory of your Photoshop application folder) If you place this in your Plug-Ins folder, Photoshop will write 'ScriptListener' Javascript code for every action you do in Photoshop (a text file with this code will appear on your desktop). This is a way to script parts of the application that are not otherwise exposed with Javascript commands.
Note - it's not exactly the Javascript that you would normally write, it can take a little getting used to to figure out what the steps it writes mean, but you can often determine what each variable it uses is for. You usually wouldn't use this for programming things that can be done with the Javascript commands available, only when there is no command to perform the task you need.
You'll probably want to remove the plug-in for normal use, and only reinstall it to record the steps that you need. Since it continuously writes to the text file for everything you do in Photoshop, finding the steps you want can be difficult if you have been 'recording' for a while. Plus, many have claimed that it slows Photoshop down as it is writing the text for each action you do. Personally, I only install mine when I need it, mostly for the first reason.
Copy link to clipboard
Copied
What I do instead of installing and uninstalling the plugin, I set the log files to read only when I don't want the output logged. For that matter I always the the VB log set to read only as I only use the JS version.
By toggling the log's read only property you can turn the pluging 'on' and 'off' without restarting Photoshop.
Copy link to clipboard
Copied
I installed the ScriptingListener.plugin and now able to see the log(what photoshop is doing) on my desktop
var id62 = stringIDToTypeID( "antialiasGloss" );
desc6.putBoolean( id62, false );
var id63 = charIDToTypeID( "Sftn" );
var id64 = charIDToTypeID( "#Pxl" );
desc6.putUnitDouble( id63, id64, 0.000000 );
var id65 = stringIDToTypeID( "useShape" );
desc6.putBoolean( id65, false );
var id66 = stringIDToTypeID( "useTexture" );
desc6.putBoolean( id66, false );
In the sample script inside Photoshop he gave it as
apply layer style art layer 1 of current document using "Blue Glass (Button)"
apply layer style theTextLayer using "antialiasGloss"
"antialiasGloss" is the value that I obtained from Script listener. Is there way that I can I find how to apply the layer style(Bevel and Emboss-->Outer Bevel)
Copy link to clipboard
Copied
Once you have got the info from the script listener log you should be able to create a function from it controlling it with some vairables kind of like this:
#target photoshop
app.bringToFront();
var docRef = app.activeDocument;
LayerDropShadow(0,0,0,75,120,20,5,10,3)
LayerBevelEmboss(255,255,255,50,0,0,0,75,120,30,80,12,3)
// This will wipe any previous layer styling
function LayerDropShadow(R,G,B,opacity,angle,distance,spread,size,noise) {
function cTID(s) { return app.charIDToTypeID(s); };
function sTID(s) { return app.stringIDToTypeID(s); };
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putProperty( cTID('Prpr'), cTID('Lefx') );
ref1.putEnumerated( cTID('Lyr '), cTID('Ordn'), cTID('Trgt') );
desc1.putReference( cTID('null'), ref1 );
var desc2 = new ActionDescriptor();
desc2.putUnitDouble( cTID('Scl '), cTID('#Prc'), 208.333333 ); // Don't know what this is?
var desc3 = new ActionDescriptor();
desc3.putBoolean( cTID('enab'), true );
desc3.putEnumerated( cTID('Md '), cTID('BlnM'), cTID('Mltp') );
var desc4 = new ActionDescriptor();
desc4.putDouble( cTID('Rd '), R );
desc4.putDouble( cTID('Grn '), G );
desc4.putDouble( cTID('Bl '), B );
desc3.putObject( cTID('Clr '), cTID('RGBC'), desc4 );
desc3.putUnitDouble( cTID('Opct'), cTID('#Prc'), opacity );
desc3.putBoolean( cTID('uglg'), true );
desc3.putUnitDouble( cTID('lagl'), cTID('#Ang'), angle );
desc3.putUnitDouble( cTID('Dstn'), cTID('#Pxl'), distance );
desc3.putUnitDouble( cTID('Ckmt'), cTID('#Pxl'), spread );
desc3.putUnitDouble( cTID('blur'), cTID('#Pxl'), size );
desc3.putUnitDouble( cTID('Nose'), cTID('#Prc'), noise );
desc3.putBoolean( cTID('AntA'), false );
var desc5 = new ActionDescriptor();
desc5.putString( cTID('Nm '), "Linear" );
desc3.putObject( cTID('TrnS'), cTID('ShpC'), desc5 );
desc3.putBoolean( sTID('layerConceals'), true );
desc2.putObject( cTID('DrSh'), cTID('DrSh'), desc3 );
desc1.putObject( cTID('T '), cTID('Lefx'), desc2 );
executeAction( cTID('setd'), desc1, DialogModes.NO );
};
// This will wipe any previous layer styling
function LayerBevelEmboss(hR,hG,hB,hOpacity,sR,sG,sB,sOpacity,angle,altitude,depth,size,soften) {
function cTID(s) { return app.charIDToTypeID(s); };
function sTID(s) { return app.stringIDToTypeID(s); };
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putProperty( cTID('Prpr'), cTID('Lefx') );
ref1.putEnumerated( cTID('Lyr '), cTID('Ordn'), cTID('Trgt') );
desc1.putReference( cTID('null'), ref1 );
var desc2 = new ActionDescriptor();
desc2.putUnitDouble( cTID('Scl '), cTID('#Prc'), 416.666667 ); // Don't know what this is?
var desc3 = new ActionDescriptor();
desc3.putBoolean( cTID('enab'), true );
desc3.putEnumerated( cTID('hglM'), cTID('BlnM'), cTID('Scrn') );
var desc4 = new ActionDescriptor();
desc4.putDouble( cTID('Rd '), hR );
desc4.putDouble( cTID('Grn '), hG );
desc4.putDouble( cTID('Bl '), hB );
desc3.putObject( cTID('hglC'), cTID('RGBC'), desc4 );
desc3.putUnitDouble( cTID('hglO'), cTID('#Prc'), hOpacity );
desc3.putEnumerated( cTID('sdwM'), cTID('BlnM'), cTID('Mltp') );
var desc5 = new ActionDescriptor();
desc5.putDouble( cTID('Rd '), sR );
desc5.putDouble( cTID('Grn '), sG );
desc5.putDouble( cTID('Bl '), sB );
desc3.putObject( cTID('sdwC'), cTID('RGBC'), desc5 );
desc3.putUnitDouble( cTID('sdwO'), cTID('#Prc'), sOpacity );
desc3.putEnumerated( cTID('bvlT'), cTID('bvlT'), cTID('SfBL') );
desc3.putEnumerated( cTID('bvlS'), cTID('BESl'), cTID('InrB') );
desc3.putBoolean( cTID('uglg'), true );
desc3.putUnitDouble( cTID('lagl'), cTID('#Ang'), angle );
desc3.putUnitDouble( cTID('Lald'), cTID('#Ang'), altitude );
desc3.putUnitDouble( cTID('srgR'), cTID('#Prc'), depth );
desc3.putUnitDouble( cTID('blur'), cTID('#Pxl'), size );
desc3.putEnumerated( cTID('bvlD'), cTID('BESs'), cTID('In ') );
var desc6 = new ActionDescriptor();
desc6.putString( cTID('Nm '), "Linear" );
desc3.putObject( cTID('TrnS'), cTID('ShpC'), desc6 );
desc3.putBoolean( sTID('antialiasGloss'), false );
desc3.putUnitDouble( cTID('Sftn'), cTID('#Pxl'), soften );
desc3.putBoolean( sTID('useShape'), false );
desc3.putBoolean( sTID('useTexture'), false );
desc2.putObject( cTID('ebbl'), cTID('ebbl'), desc3 );
desc1.putObject( cTID('T '), cTID('Lefx'), desc2 );
executeAction( cTID('setd'), desc1, DialogModes.NO );
};
Copy link to clipboard
Copied
The line putUnitDouble( cTID('Scl '), cTID('#Prc'), 416.666667 ); is for the scale of that layer's effects. If you resize a doc in the GUI you will see a checkbox for 'Scale Styles'. That seems to where that value comes into play. It seems to be baised on the doc's ppi ie a 72ppi doc will have a scale value of 100.000. 240ppi = 333.333. 300ppi =416.666. So in the code Mark posted one style was recorded at 150ppi and the other at 300ppi
Changing that value doesn't seem to have any effect when creating the style using scriptlistner code with the styles I have tested so you not need to worry about matching the scale to the ppi. However to be on the safe side I would set the scale to the correct setting for the doc ppi.
Mike
Copy link to clipboard
Copied
Mike that is spot on I could not work out what this figure related to but that is good to know.
Copy link to clipboard
Copied
In the PDF scripting guide he gave it as
apply layer style art layer 1 of current document using "Blue Glass (Button)" #This will work
apply layer style theTextLayer using "antialiasGloss" #this is not working. Dont know whether it is correct or not?
"antialiasGloss" is the value that I obtained from Script listener.
Is there way that I can to apply the layer style(Bevel and Emboss-->Outer Bevel)
Copy link to clipboard
Copied
I think that you do not understand how to use the scriptlistner plugin. You can not use just part of the log like
apply layer style theTextLayer using "antialiasGloss"
"antialiasGloss" that is from the scriptlistner log is just part of the action descriptor that photoshop needs to perform the action. You need to include everything in that step. You can clean it up and make it into a function as Mark did in his post.
Copy link to clipboard
Copied
Thanks Michael,
I am new to photoshop scripting and really don't know how the script listener plugin works. But for my use I do it with applescript where I need not write any function(presently) where I need to enable the Bevel and Emboss option in the Layer style and in the dropdown just select OuterBevel..thats it I do not want to perform any actions at this point of time.
Copy link to clipboard
Copied
I posted a solution for AppleScript in your other thread "Photoshop Script Record" you might want to check that.
Copy link to clipboard
Copied
You are very helpful earlier, the applescript which includes the javascript function will set all the values for the layer for the Blending Options, but that is not the case for me, I want to set the layer style(current layer in the document) to Bevel and Emboss-->OuterBevel(Value in Combo)
P.S- The script which you provided will help me to set the values for the blending options
Copy link to clipboard
Copied
With the scriptlistner plugin installed create an outerbevel with the settings you require. Then before doing anything else in Photoshop open the scriptlistnerJS log and find the last entry. It should look something like this. This is an outerbevel with the default settings.
// =======================================================
var idsetd = charIDToTypeID( "setd" );
var desc9074 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
var ref109 = new ActionReference();
var idPrpr = charIDToTypeID( "Prpr" );
var idLefx = charIDToTypeID( "Lefx" );
ref109.putProperty( idPrpr, idLefx );
var idLyr = charIDToTypeID( "Lyr " );
var idOrdn = charIDToTypeID( "Ordn" );
var idTrgt = charIDToTypeID( "Trgt" );
ref109.putEnumerated( idLyr, idOrdn, idTrgt );
desc9074.putReference( idnull, ref109 );
var idT = charIDToTypeID( "T " );
var desc9075 = new ActionDescriptor();
var idScl = charIDToTypeID( "Scl " );
var idPrc = charIDToTypeID( "#Prc" );
desc9075.putUnitDouble( idScl, idPrc, 416.666667 );
var idebbl = charIDToTypeID( "ebbl" );
var desc9076 = new ActionDescriptor();
var idenab = charIDToTypeID( "enab" );
desc9076.putBoolean( idenab, true );
var idhglM = charIDToTypeID( "hglM" );
var idBlnM = charIDToTypeID( "BlnM" );
var idScrn = charIDToTypeID( "Scrn" );
desc9076.putEnumerated( idhglM, idBlnM, idScrn );
var idhglC = charIDToTypeID( "hglC" );
var desc9077 = new ActionDescriptor();
var idRd = charIDToTypeID( "Rd " );
desc9077.putDouble( idRd, 255.000000 );
var idGrn = charIDToTypeID( "Grn " );
desc9077.putDouble( idGrn, 255.000000 );
var idBl = charIDToTypeID( "Bl " );
desc9077.putDouble( idBl, 255.000000 );
var idRGBC = charIDToTypeID( "RGBC" );
desc9076.putObject( idhglC, idRGBC, desc9077 );
var idhglO = charIDToTypeID( "hglO" );
var idPrc = charIDToTypeID( "#Prc" );
desc9076.putUnitDouble( idhglO, idPrc, 75.000000 );
var idsdwM = charIDToTypeID( "sdwM" );
var idBlnM = charIDToTypeID( "BlnM" );
var idMltp = charIDToTypeID( "Mltp" );
desc9076.putEnumerated( idsdwM, idBlnM, idMltp );
var idsdwC = charIDToTypeID( "sdwC" );
var desc9078 = new ActionDescriptor();
var idRd = charIDToTypeID( "Rd " );
desc9078.putDouble( idRd, 0.000000 );
var idGrn = charIDToTypeID( "Grn " );
desc9078.putDouble( idGrn, 0.000000 );
var idBl = charIDToTypeID( "Bl " );
desc9078.putDouble( idBl, 0.000000 );
var idRGBC = charIDToTypeID( "RGBC" );
desc9076.putObject( idsdwC, idRGBC, desc9078 );
var idsdwO = charIDToTypeID( "sdwO" );
var idPrc = charIDToTypeID( "#Prc" );
desc9076.putUnitDouble( idsdwO, idPrc, 75.000000 );
var idbvlT = charIDToTypeID( "bvlT" );
var idbvlT = charIDToTypeID( "bvlT" );
var idSfBL = charIDToTypeID( "SfBL" );
desc9076.putEnumerated( idbvlT, idbvlT, idSfBL );
var idbvlS = charIDToTypeID( "bvlS" );
var idBESl = charIDToTypeID( "BESl" );
var idOtrB = charIDToTypeID( "OtrB" );
desc9076.putEnumerated( idbvlS, idBESl, idOtrB );
var iduglg = charIDToTypeID( "uglg" );
desc9076.putBoolean( iduglg, true );
var idlagl = charIDToTypeID( "lagl" );
var idAng = charIDToTypeID( "#Ang" );
desc9076.putUnitDouble( idlagl, idAng, 120.000000 );
var idLald = charIDToTypeID( "Lald" );
var idAng = charIDToTypeID( "#Ang" );
desc9076.putUnitDouble( idLald, idAng, 30.000000 );
var idsrgR = charIDToTypeID( "srgR" );
var idPrc = charIDToTypeID( "#Prc" );
desc9076.putUnitDouble( idsrgR, idPrc, 100.000000 );
var idblur = charIDToTypeID( "blur" );
var idPxl = charIDToTypeID( "#Pxl" );
desc9076.putUnitDouble( idblur, idPxl, 5.000000 );
var idbvlD = charIDToTypeID( "bvlD" );
var idBESs = charIDToTypeID( "BESs" );
var idIn = charIDToTypeID( "In " );
desc9076.putEnumerated( idbvlD, idBESs, idIn );
var idTrnS = charIDToTypeID( "TrnS" );
var desc9079 = new ActionDescriptor();
var idNm = charIDToTypeID( "Nm " );
desc9079.putString( idNm, "Linear" );
var idShpC = charIDToTypeID( "ShpC" );
desc9076.putObject( idTrnS, idShpC, desc9079 );
var idantialiasGloss = stringIDToTypeID( "antialiasGloss" );
desc9076.putBoolean( idantialiasGloss, false );
var idSftn = charIDToTypeID( "Sftn" );
var idPxl = charIDToTypeID( "#Pxl" );
desc9076.putUnitDouble( idSftn, idPxl, 0.000000 );
var iduseShape = stringIDToTypeID( "useShape" );
desc9076.putBoolean( iduseShape, false );
var iduseTexture = stringIDToTypeID( "useTexture" );
desc9076.putBoolean( iduseTexture, false );
var idebbl = charIDToTypeID( "ebbl" );
desc9075.putObject( idebbl, idebbl, desc9076 );
var idLefx = charIDToTypeID( "Lefx" );
desc9074.putObject( idT, idLefx, desc9075 );
executeAction( idsetd, desc9074, DialogModes.NO );
You need to include all of those lines in the code that you call with your applescript.