Skip to main content
Known Participant
March 2, 2017
Answered

How to apply style on the active layerSet with Js?

  • March 2, 2017
  • 1 reply
  • 1524 views

Hi, I am new in Js and so far I am capable of applying styles on artLayers with Js.

This is my code for that

app.activeDocument.artLayers["artLayer Name"].applyStyle("Name of the Style");

But I don't know how to apply a style on the active layerSet. It will be really helpful to apply a style on a folder because  that way I will apply the same effect in all the layerSet's contents.

Can you help me?

This topic has been closed for replies.
Correct answer pixxxelschubser

Hi evangelos.vlasopoulos,

layer sets does not have the method applyStyle().

But you can do the same with ActionManager code (it's JavaScript compatible)

var yourStyle = "Pyramide"; // your own style name

var laySet = "Gruppe 1"; // your own layer set name

(ref1 = new ActionReference()).putName(stringIDToTypeID('style'), yourStyle);

(desc = new ActionDescriptor()).putReference(stringIDToTypeID('null'), ref1);

(ref2 = new ActionReference()).putName(stringIDToTypeID('layer'), laySet)

desc.putReference(stringIDToTypeID('to'), ref2)

desc.putBoolean(stringIDToTypeID('group'), true)

executeAction(stringIDToTypeID('applyStyle'), desc, DialogModes.NO);

The previous code will apply the (existing!) style with name "Pyramide" to the layer set with name "Gruppe 1"

Have fun

1 reply

pixxxelschubser
Community Expert
pixxxelschubserCommunity ExpertCorrect answer
Community Expert
March 2, 2017

Hi evangelos.vlasopoulos,

layer sets does not have the method applyStyle().

But you can do the same with ActionManager code (it's JavaScript compatible)

var yourStyle = "Pyramide"; // your own style name

var laySet = "Gruppe 1"; // your own layer set name

(ref1 = new ActionReference()).putName(stringIDToTypeID('style'), yourStyle);

(desc = new ActionDescriptor()).putReference(stringIDToTypeID('null'), ref1);

(ref2 = new ActionReference()).putName(stringIDToTypeID('layer'), laySet)

desc.putReference(stringIDToTypeID('to'), ref2)

desc.putBoolean(stringIDToTypeID('group'), true)

executeAction(stringIDToTypeID('applyStyle'), desc, DialogModes.NO);

The previous code will apply the (existing!) style with name "Pyramide" to the layer set with name "Gruppe 1"

Have fun

Known Participant
March 2, 2017

Thank you very much my friend! That did the trick!