-
1. Re: Copy Shape Attributes & Layer Style from one layer & paste to another?
c.pfaffenbichler Jan 29, 2014 7:01 AM (in response to Juano Hunt)A try-clause seem to be an option.
try {
…
}
catch (e) {}
Checking for Layer Styles is possible, too.
var ref = new ActionReference();
ref.putEnumerated( charIDToTypeID("Lyr "), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
var layerDesc = executeActionGet(ref);
var hasLayerFx = layerDesc.hasKey(stringIDToTypeID('layerEffects'));
if (hasLayerFx == true) {alert ("layer effects")}
else {alert ("no layer effects")};
-
2. Re: Copy Shape Attributes & Layer Style from one layer & paste to another?
Juano Hunt Jan 29, 2014 7:27 AM (in response to c.pfaffenbichler)Thanks! The try-clause thing stops me from getting the error messge
I'm not sure how to use the 'checking for Layer Styles' part. Does it check for Layer Styles and copy them if they're present and ignore/not try to copy if they're not present?
Now that it's working (without an error message), when copying if Layer Styles aren't present on the layer being copied, is it possible to delete Layer Styles (or set Layer Styles to none) on the layer where you're pasting?
-
3. Re: Copy Shape Attributes & Layer Style from one layer & paste to another?
c.pfaffenbichler Jan 29, 2014 7:33 AM (in response to Juano Hunt)I'm not sure how to use the 'checking for Layer Styles' part. Does it check for Layer Styles and copy them if they're present and ignore/not try to copy if they're not present?
It just checks, you can then have the Script do different things depending on the outcome.
-
4. Re: Copy Shape Attributes & Layer Style from one layer & paste to another?
Juano Hunt Jan 29, 2014 7:52 AM (in response to c.pfaffenbichler)Thanks again.
For the copying script this seems to work OK. Does it look OK, or could there be any problems?
// Copy Shape Attributes
try {
var idshapeClipboardOperation = stringIDToTypeID( "shapeClipboardOperation" );
var desc4 = new ActionDescriptor();
var idshapeClipboardOperation = stringIDToTypeID( "shapeClipboardOperation" );
var idshapeClipboardOperation = stringIDToTypeID( "shapeClipboardOperation" );
var idshapeCopyShapeAll = stringIDToTypeID( "shapeCopyShapeAll" );
desc4.putEnumerated( idshapeClipboardOperation, idshapeClipboardOperation, idshapeCopyShapeAll );
executeAction( idshapeClipboardOperation, desc4, DialogModes.NO );
}
catch (e) {}
// Check if Layer Styles exist
var ref = new ActionReference();
ref.putEnumerated( charIDToTypeID("Lyr "), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
var layerDesc = executeActionGet(ref);
var hasLayerFx = layerDesc.hasKey(stringIDToTypeID('layerEffects'));
if (hasLayerFx == true)
// Copy Layer Styles
try {
var idCpFX = charIDToTypeID( "CpFX" );
executeAction( idCpFX, undefined, DialogModes.NO );
}
catch (e) {}
//Do nothing
else {"Do Nothing"};
-
5. Re: Copy Shape Attributes & Layer Style from one layer & paste to another?
c.pfaffenbichler Jan 29, 2014 11:31 PM (in response to Juano Hunt)Come to think of it Layer Style is not determined by Layer Styles alone, Blend Mode, Opacity and Fill also count.
-
6. Re: Copy Shape Attributes & Layer Style from one layer & paste to another?
Juano Hunt Jan 30, 2014 3:36 AM (in response to c.pfaffenbichler)Ah, maybe I should just stick with the try-clause thing so it tries to copy Layer Styles even if the layer doesn't have any, and fails silently then.
Thanks.

