Skip to main content
November 21, 2008
Question

Offset Path method?

  • November 21, 2008
  • 14 replies
  • 6070 views
Hi there,

Does anyone know if there is a method in the Illustrator DOM that allows you to do the equivalent of the Offset Path command (found in the Object / Path menu of the Illustrator UI)? I am working with JavaScript (using the ESTK) and have both CS3 & CS4 but cannot find it anywhere in the documentation. If this does not exist, what would be the most appropriate / effective way to request that it be added to the DOM - I really need this feature for the project I am working on.

Many thanks,

Andy McDonald (Scotland)
This topic has been closed for replies.

14 replies

c.pfaffenbichler
Community Expert
Community Expert
April 1, 2009
Kind of a follow-up:
For some purposes I had to use the expanded results of the offset paths and couldnt find a direct way to Expand Appearance via JavaScript.
But I found I could force that by saving as an Illustrator 8-file with
flattenSaveOptions.compatibility = Compatibility.ILLUSTRATOR8;
flattenSaveOptions.flattenOutput = OutputFlattening.PRESERVEAPPEARANCE;
then close and open that and copy/paste the resulting elements back into the document.
Known Participant
March 26, 2009
Dr Woohoo knows his stuff!
c.pfaffenbichler
Community Expert
Community Expert
March 26, 2009
Andy, thats some good workaround, thanks for sharing it!
March 24, 2009
Hi again,

It seems I forgot to subscribe to my own forum topic - I just assumed there had been no response! With the help of Dr Woohoo, I managed to find a semi-workaround that suits my needs for the moment. Basically, you need to create a new Graphic Style using the Appearance panel (where you can access the Offset Path feature through the FX options) and save it. From there you can use 'document.graphicStyles.getByName("Graphic Style Name");' in conjunction with the applyTo() and mergeTo() methods. The only downside is that you do not have access to the offset amount as a variable therefore the value must be hard-coded when you create the graphic style (ie: a separate graphic style must be created for each offset amount you intend to use).

Hope this helps...

Cheers,

Andy McDonald
Known Participant
February 19, 2009
Totally correct, again.
c.pfaffenbichler
Community Expert
Community Expert
February 19, 2009
Well, any irregular shape will produce different results with Scaling instead of Offsetting, even rectangles (edit: with the exception of the square).
Doesnt it seem a bit strange though to have to try and mathematically recreate a function that already exists in Illustrator?
Albeit regrettably out of Scriptings reach, it seems.
Known Participant
February 19, 2009
True. I was thinking about letter 'S' just after I posted.

The maths involved seems complex. Even if scripting could sample the anchor point co-ords (x,y) and move them, the mapping is not fully apparent to me.

I tried scaling various parts of the 'S' to match a +4 mm offset and there's no easy correlation.

Any ideas on the function? Can AI scripting move anchor points and curve handles?

Nodebox?
MarkWalsh
Inspiring
February 18, 2009
It has nothing to do with compound shapes. Simple shapes (squares, circles, octagons) will have the same effect when scaling as an offset path, but try the same to the letter 'S'. Doesn't work. Offset Path expands the shape in all directions perpendicularly.

Unfortunately, the methods available to the path item are limited. I don't think there is any way to work with the paths like you can in the UI other than the few methods that are available.
Known Participant
February 18, 2009
@christoph

that's totally correct. object would have to separated into non-compound shapes and expanded and contracted according to inside/outside path quality. The script just got a whole lot more complicated...

still if wanting to do a whole lot of offsets and non-compound shapes are being used script should be fast.
c.pfaffenbichler
Community Expert
Community Expert
February 18, 2009
WEP, as I understand it Offset Path and Scaling are two very different things.
If for example one had a form with a hole, Offset Path (with a positive value) would close that hole at some point, whereas Scaling would never close the hole.