Search code examples
extendscriptphotoshop-script

Getting text layer shadow parameters (ExtendScript CS5, Photoshop scripting)


Is there any way to get text(or any other) layer shadow params in Adobe Photoshop CS5 using ExtendScript for further convertion to CSS3 like text string?

Thanks!


Solution

  • There is a way.

    You have to use the ActionManager:

    var ref = new ActionReference();
    ref.putEnumerated( charIDToTypeID("Lyr "), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") ); 
    var desc = executeActionGet(ref).getObjectValue(stringIDToTypeID('layerEffects')).getObjectValue(stringIDToTypeID('dropShadow'));
    desc.getUnitDoubleValue(stringIDToTypeID('distance'))
    

    Where "dropShadow" is the layereffect you want to read and for example "distance" is the parameter that will be returned. Other layereffects and parameters are only known as eventids. Look in the documentation (bad documented) if you need other eventids.

    The next AM-Code will check if there is a layerstyle shadow.

    var res = false;
    var ref = new ActionReference();
    ref.putEnumerated( charIDToTypeID("Lyr "), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") ); 
    var hasFX =  executeActionGet(ref).hasKey(stringIDToTypeID('layerEffects'));
    if ( hasFX ){
    var ref = new ActionReference();
    ref.putEnumerated( charIDToTypeID("Lyr "), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") ); 
    res = executeActionGet(ref).getObjectValue(stringIDToTypeID('layerEffects')).hasKey(stringIDToTypeID('dropShadow'));
        }
    return res;
    

    This will explain http://forums.adobe.com/thread/714406 more.

    If you find a way to SET the shadow, without setting other params, let me know...