Famouse
Famouse

Reputation: 43

How to get all Photoshop styles?

I want to randomly apply styles to my ArtLayers. To do this, I tested the applyStyle function.

ArtLayers.applyStyle

1

It works!)

But to solve my task I need all styles. I can't find it in the documentation (photoshop-javascript-ref-2020).

Can you suggest something?

Upvotes: 0

Views: 95

Answers (1)

Ghoul Fool
Ghoul Fool

Reputation: 6949

To get all the styles use this Action Manager function:

var allStyles = get_styles()
alert(allStyles); // ALLL the styles!
//alert(allStyles[22]); // Sunspots (texture)

function get_styles()
{
  var ref = new ActionReference(); 
  ref.putEnumerated( charIDToTypeID("capp"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") ); 
  var appDesc = executeActionGet(ref); 
  var List = appDesc.getList(stringIDToTypeID('presetManager'));
  var list = List.getObjectValue(3).getList(charIDToTypeID('Nm  '));
  var styleNames=[];

  for (var i = 0; i < list.count; i++)
  {
    var str = list.getString(i);
    styleNames.push(str);
  }

  return styleNames;
}

Upvotes: 1

Related Questions