Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Get information about layer styles with script

New Here ,
Aug 05, 2009 Aug 05, 2009

Is there a way for a script to get information about the currently existing layer styles on a layer?

For example, can I find out if a layer has a dropShadow, and if so, can I find that dropShadow's size, transparency, color, etc...?

TOPICS
Actions and scripting
1.5K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Guru , Aug 05, 2009 Aug 05, 2009

If you don't have CS4 you will need Xbytor's script. With CS4 you can the the descriptor from the layer

var ref = new ActionReference();
ref.putEnumerated( charIDToTypeID("Lyr "), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
var desc = executeActionGet(ref).getObjectValue(stringIDToTypeID('layerEffects'));
if( desc.hasKey( stringIDToTypeID('dropShadow') ) ){
     desc = desc.getObjectValue(stringIDToTypeID('dropShadow'));
     alert('opacity = '+ desc.getDouble( stringIDToTypeID('opacity') ) );
 
...
Translate
Adobe
Advisor ,
Aug 05, 2009 Aug 05, 2009

There is no easy way to get this information, but you can get to it.

Get my xtools library (from ps-scripts.sourceforge.net) and in there you will find xtools/xlib/Styles.js.

In there, you will find Styles.getLayerStyleDescriptor(). The will get you the ActionDescriptor that

describes the styles applied to a layer.

-X

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 05, 2009 Aug 05, 2009

haven't tried it out yet, but from a quick glance at it that looks like a really useful collection of tools - thanks for sharing!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Aug 05, 2009 Aug 05, 2009

If you don't have CS4 you will need Xbytor's script. With CS4 you can the the descriptor from the layer

var ref = new ActionReference();
ref.putEnumerated( charIDToTypeID("Lyr "), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
var desc = executeActionGet(ref).getObjectValue(stringIDToTypeID('layerEffects'));
if( desc.hasKey( stringIDToTypeID('dropShadow') ) ){
     desc = desc.getObjectValue(stringIDToTypeID('dropShadow'));
     alert('opacity = '+ desc.getDouble( stringIDToTypeID('opacity') ) );
     alert('distance = '+ desc.getDouble( stringIDToTypeID('distance') ) );
     alert('spread = '+ desc.getDouble( stringIDToTypeID('chokeMatte') ) );// spread
     alert('blur = '+ desc.getDouble( stringIDToTypeID('blur') ) );
     var desc = desc.getObjectValue(stringIDToTypeID('color'));
     var r = desc.getDouble( stringIDToTypeID('red') ) ;
     var g = desc.getDouble( stringIDToTypeID('green') ) ;
     var b = desc.getDouble( stringIDToTypeID('blue') ) ;
     alert( 'r = ' + r +'\rg = ' + g + '\rb = ' + b );
}
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 05, 2009 Aug 05, 2009
LATEST

Sweet.  That's even easier

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines