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:
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.
In my AppleScript Debugger I was able to open up a Dictionary and see:
applyeffect (verb)Apply effect to selected artItem (from Adobe Illustrator Suite)
applyeffect page item ¬
the page item object or objects to be operated upon
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
Wow... it works! This is exactly what I need
Thank you very much Silly
I guess I just can't leave things alone sometimes
I hear you...
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…?
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>";
yes, but how to do that in AS?
I got it!!!
Thank you SILLY-D
Lol I forgot the AS part