Copy link to clipboard
Copied
Hi, I tried google, chatGPT and Adobe docs to find out how to do it. Tried to debug with vscode and I can't find how to do it.
I mess too much the script, but I basically create a text layer with a string inside it.
This is chatGPT script that doesn't work:
// Reference to the active document
var docRef = app.activeDocument;
// Reference to the active layer
var layerRef = docRef.activeLayer;
// Ensure the layer is not a background layer
if (!layerRef.isBackgroundLayer) {
// Access the Drop Shadow effect
var dropShadow = layerRef.layerEffects.dropShadow;
// Enable the Drop Shadow effect
dropShadow.enabled = true;
// Customize the Drop Shadow properties
dropShadow.mode = BlendMode.MULTIPLY; // Set the blend mode (e.g., Multiply)
dropShadow.color = new SolidColor(); // Define the shadow color
dropShadow.color.rgb.hexValue = "000000"; // Set the color to black (#000000)
dropShadow.opacity = 75; // Set the opacity (0 to 100)
dropShadow.distance = 10; // Set the distance in pixels
dropShadow.size = 10; // Set the size in pixels
dropShadow.angle = 120; // Set the angle in degrees
dropShadow.useGlobalLight = true; // Use global light settings
// Notify the user that the style has been applied
alert("Drop Shadow has been applied to the active layer.");
} else {
alert("The active layer is a background layer and cannot have styles applied.");
}
Is there a way to do it in a script?
Thanks
You can use the following to apply a layer style drop shadow, however, if there are any other styles applied they will be lost:
var s2t = function (s) {
return app.stringIDToTypeID(s);
};
var descriptor = new ActionDescriptor();
var descriptor2 = new ActionDescriptor();
var descriptor3 = new ActionDescriptor();
var descriptor4 = new ActionDescriptor();
var descriptor5 = new ActionDescriptor();
var reference = new ActionReference();
reference.putProperty( s2t( "property" ), s2t( "layerEffect
...
Copy link to clipboard
Copied
// Reference to the active document
var docRef = app.activeDocument;
// Reference to the active layer
var layerRef = docRef.activeLayer;
// Ensure the layer is not a background layer
if (!layerRef.isBackgroundLayer) {
// Access the Drop Shadow effect
var dropShadow = layerRef.layerEffects.dropShadow;
// Enable the Drop Shadow effect
dropShadow.enabled = true;
// Customize the Drop Shadow properties
dropShadow.mode = BlendMode.MULTIPLY; // Set the blend mode (e.g., Multiply)
dropShadow.color = new SolidColor(); // Define the shadow color
dropShadow.color.rgb.hexValue = "000000"; // Set the color to black (#000000)
dropShadow.opacity = 75; // Set the opacity (0 to 100)
dropShadow.distance = 10; // Set the distance in pixels
dropShadow.size = 10; // Set the size in pixels
dropShadow.angle = 120; // Set the angle in degrees
dropShadow.useGlobalLight = true; // Use global light settings
// Notify the user that the style has been applied
alert("Drop Shadow has been applied to the active layer.");
} else {
alert("The active layer is a background layer and cannot have styles applied.");
}
Copy link to clipboard
Copied
You can use the following to apply a layer style drop shadow, however, if there are any other styles applied they will be lost:
var s2t = function (s) {
return app.stringIDToTypeID(s);
};
var descriptor = new ActionDescriptor();
var descriptor2 = new ActionDescriptor();
var descriptor3 = new ActionDescriptor();
var descriptor4 = new ActionDescriptor();
var descriptor5 = new ActionDescriptor();
var reference = new ActionReference();
reference.putProperty( s2t( "property" ), s2t( "layerEffects" ));
reference.putEnumerated( s2t( "layer" ), s2t( "ordinal" ), s2t( "targetEnum" ));
descriptor.putReference( s2t( "null" ), reference );
descriptor2.putUnitDouble( s2t( "scale" ), s2t( "percentUnit" ), 100.000000 );
descriptor3.putBoolean( s2t( "enabled" ), true );
descriptor3.putBoolean( s2t( "present" ), true );
descriptor3.putBoolean( s2t( "showInDialog" ), true );
descriptor3.putEnumerated( s2t( "mode" ), s2t( "blendMode" ), s2t( "multiply" ));
descriptor4.putDouble( s2t( "luminance" ), 0.000000 );
descriptor4.putDouble( s2t( "a" ), 0.000000 );
descriptor4.putDouble( s2t( "b" ), 0.000000 );
descriptor3.putObject( s2t( "color" ), s2t( "labColor" ), descriptor4 );
descriptor3.putUnitDouble( s2t( "opacity" ), s2t( "percentUnit" ), 48.000000 );
descriptor3.putBoolean( s2t( "useGlobalAngle" ), true );
descriptor3.putUnitDouble( s2t( "localLightingAngle" ), s2t( "angleUnit" ), 90.000000 );
descriptor3.putUnitDouble( s2t( "distance" ), s2t( "pixelsUnit" ), 8.000000 );
descriptor3.putUnitDouble( s2t( "chokeMatte" ), s2t( "pixelsUnit" ), 10.000000 );
descriptor3.putUnitDouble( s2t( "blur" ), s2t( "pixelsUnit" ), 13.000000 );
descriptor3.putUnitDouble( s2t( "noise" ), s2t( "percentUnit" ), 0.000000 );
descriptor3.putBoolean( s2t( "antiAlias" ), false );
descriptor5.putString( s2t( "name" ), "Linear" );
descriptor3.putObject( s2t( "transferSpec" ), s2t( "shapeCurveType" ), descriptor5 );
descriptor3.putBoolean( s2t( "layerConceals" ), true );
descriptor2.putObject( s2t( "dropShadow" ), s2t( "dropShadow" ), descriptor3 );
descriptor.putObject( s2t( "to" ), s2t( "layerEffects" ), descriptor2 );
executeAction( s2t( "set" ), descriptor, DialogModes.NO );