Skip to main content
Participant
May 23, 2018
Answered

Change Object Style with Script

  • May 23, 2018
  • 1 reply
  • 1201 views

I have a bunch of templates that have an applied object style and i need to change the stroke attribute from 1pt black to [None]. How can i achieve this with a script?

This topic has been closed for replies.
Correct answer Benreyn

Wouldn't it make more sense to change it from 1pt to 0pt?

I don't know if this will help you, but the script below will remove/make the stroke on all items, on all pages to 0pt:

var doc = app.activeDocument;

for(var i = 0; i < doc.pages.length; i++) {

    doc.pages.item(i).pageItems.everyItem().strokeWeight = 0;

}

EDIT: You could also target the Object Style directly, I think that is what you are really looking for, see below:

var doc = app.activeDocument;

for(var i = 0; i < doc.pages.length; i++) {

    doc.objectStyles.itemByName("myObjectStyle").strokeColor = "None";

}

Hope this points you in the right direction.

1 reply

Benreyn
BenreynCorrect answer
Participating Frequently
May 24, 2018

Wouldn't it make more sense to change it from 1pt to 0pt?

I don't know if this will help you, but the script below will remove/make the stroke on all items, on all pages to 0pt:

var doc = app.activeDocument;

for(var i = 0; i < doc.pages.length; i++) {

    doc.pages.item(i).pageItems.everyItem().strokeWeight = 0;

}

EDIT: You could also target the Object Style directly, I think that is what you are really looking for, see below:

var doc = app.activeDocument;

for(var i = 0; i < doc.pages.length; i++) {

    doc.objectStyles.itemByName("myObjectStyle").strokeColor = "None";

}

Hope this points you in the right direction.

Participant
May 24, 2018

Thank you. Thats what i was looking for.