Search code examples
applescriptadobe-illustrator

Using applescript to change stroke weights conditionally in Illustrator CS6


I was trying to use this code.

tell application "Adobe Illustrator"
    tell front document
        set properties of every path item whose stroke weight is less than 0.2 to {stroke width:0.2}
    end tell
end tell

I see no reason why it shouldn't work, but it gets hung up on the phrase "path item." I don't understand what else I should do! I'm trying to get this to work in Illustrator CS6.


Solution

  • Full disclosure: I'm doing this on CS4, but it really should be the same, although I suppose it is possible (unlikely) that "stroke width" changed to "stroke weight". I think you also need to specify the layer. Try something like (of course you'll have to specify the correct layer) this; it works for me:

    tell application "Adobe Illustrator"
        tell front document
            set stroke width of (every path item of layer 1 of it whose stroke width is less than 0.2) to 0.2
        end tell
    end tell