Skip to main content
jhonperezph
Participating Frequently
November 30, 2017
Answered

Applying Live effects (offset path) in Illustrator using AS

  • November 30, 2017
  • 3 replies
  • 4882 views

Help! Anyone can give me an example how to script (AS) Offset Path in Illustrator?

Thank you.

This topic has been closed for replies.
Correct answer Silly-V

In my AppleScript Debugger I was able to open up a Dictionary and see:

applyeffect

applyeffect (verb)Apply effect to selected artItem (from Adobe Illustrator Suite)

command syntax

applyeffect page item ¬

    liveeffectxml text

parameters

Parameter

Required

Type

Description

direct parameter

required

page item

the page item object or objects to be operated upon

liveeffectxml

required

text

I guess I just can't leave things alone sometimes, I was able to make this snippet work:

tell application "Adobe Illustrator"

  set doc to the first document

  set testPath to the first path item of doc

  set xmlstring to "<LiveEffect name='Adobe Offset Path'><Dict data='R mlim 4 R ofst 20 I jntp 2 '/></LiveEffect>"

  applyeffect testPath liveeffectxml xmlstring

end tell

3 replies

jhonperezph
Participating Frequently
December 6, 2017

Hi anyone,  one more question

<LiveEffect name='Adobe Offset Path'><Dict data='R mlim 4 R ofst 20 I jntp 2 '/></LiveEffect>"

Is there a way that we can make the (ofst 20) as a string…?

like offsetvalueinput

Thanks again  

Silly-V
Legend
December 6, 2017

You mean like this?
var offsetvalueinput = 20;
var liveXmlString = "<LiveEffect name='Adobe Offset Path'><Dict data='R mlim 4 R ofst " + offsetvalueinput + "  I jntp 2 '/></LiveEffect>";

jhonperezph
Participating Frequently
December 6, 2017

yes,  but how to do that in AS?

jhonperezph
Participating Frequently
December 1, 2017

Wow...   it works!    This is exactly what I need

Thank you very much Silly

Silly-V
Legend
December 1, 2017

Your answer is actually one of the most arcane Illustrator Scripting subjects, and as luck would have it, the answer is in fact the very first example provided by CarlosCanto which let us all in on the secret, and it's here: Re: PageItem.applyEffect(LiveEffectXML)

The challenge is in two parts, first you have to obtain and prepare your live effect xml syntax for the Offset Path effect and then you have to apply it with some code.

Some more AI scripting 'rules' for these live effects:

  • applying a new effect will add it to the art, compounding with previous effects
  • to reduce the effects, is possible by applying a pre-prepared 'default/no-style' graphic style or using an Action or app.executeMenuCommand(...) to reduce to basic appearance or clear appearance.
  • The effect is live, to turn it into real paths will take another action or menu command 'expand appearance'

Also one other thread which also has other effect examples is here:

Apply Live Effect: Inner Glow with color

Please enjoy this amazing Illustrator scripting feature, it's been hidden for years and is only available to us through the good graces of the powers that be.

* As for AS, just use a do javascript command - I'm not sure about the AS vocabulary for the liveEffect syntax myself and usually take the lazy way out by having my AS run my JSXs.

Silly-V
Silly-VCorrect answer
Legend
December 1, 2017

In my AppleScript Debugger I was able to open up a Dictionary and see:

applyeffect

applyeffect (verb)Apply effect to selected artItem (from Adobe Illustrator Suite)

command syntax

applyeffect page item ¬

    liveeffectxml text

parameters

Parameter

Required

Type

Description

direct parameter

required

page item

the page item object or objects to be operated upon

liveeffectxml

required

text

I guess I just can't leave things alone sometimes, I was able to make this snippet work:

tell application "Adobe Illustrator"

  set doc to the first document

  set testPath to the first path item of doc

  set xmlstring to "<LiveEffect name='Adobe Offset Path'><Dict data='R mlim 4 R ofst 20 I jntp 2 '/></LiveEffect>"

  applyeffect testPath liveeffectxml xmlstring

end tell

CarlosCanto
Community Expert
Community Expert
December 2, 2017
I guess I just can't leave things alone sometimes

I hear you...