Skip to main content
February 26, 2010
Answered

Applying a graphicStyle to a pathItem

  • February 26, 2010
  • 1 reply
  • 1164 views

I am attempting to apply a graphicStyle to a pathItem, but keep getting a "target layer cannot be modified" error.

Any ideas?

This topic has been closed for replies.
Correct answer Muppet Mark

As I read it you have go through the Document PathItems to get your compoundPathItem, you can't call it as a Layer object.


#target illustrator

var docRef = app.activeDocument;

with (docRef) {

var myGS = graphicStyles.getByName('Marks Graphic Style');

myGS.applyTo(compoundPathItems[0]);

}

Works for me…

1 reply

Larry G. Schneider
Community Expert
Community Expert
February 26, 2010

Is the layer locked or hidden in the file? Try setting the visible of the layer to true and the locked of the layer to false before attempting to apply the graphic style.

February 26, 2010

Already checked that. It is a compoundPathItem that I am applying it to BTW.

The param for applyTo is a PageItem, and compoundPathItem is a page item.

Larry G. Schneider
Community Expert
Community Expert
February 26, 2010

But did you read the bit about the paths not being returned if the target is a layer?