Skip to main content
Participating Frequently
December 23, 2014
Question

Script path arrows

  • December 23, 2014
  • 2 replies
  • 2531 views

I cannot seem to find a complete description of the Adobe Illustrator object model, only the scripting guides, which are a good start but seem to provide only a partial list...does one exist?  My immediate problem is figuring out the script add arrows to path: e.g., "turn arrows on, for both sides of selected stroke, using  arrow head 3 scaled at 50%". Easy enough to do by hand using the stroke menu, but not obvious how to do it via a script. In case it matters to the answer, am still in CS5.1. Thanks for any help.

2 replies

Known Participant
April 25, 2025

Disappointing doesn't even come close. I mean... this ruins what I just spent a bunch of time learning the scripting environment and writing. I wrote a script for a colleague to use for making numbered arrows and captions in technical diagrams... but without the ability to put an arrowhead on a line, dragging the line to the right position and rotation will be so cumbersome that it defeats the convenience I just created.

 

Unbelievable. What a shame.

Sergey Osokin
Inspiring
April 28, 2025

As Carlos wrote, you can create a graphic style template, load it into a file beforehand. Then use a script to draw the necessary lines and apply the style to them, also using the script command. Example: activeDocument.graphicStyles[1].applyTo(myPath)

 

You can also create an action that applies the 50% arrow to the end of the path. Draw the path with the script and call this action with app.doScript().

Known Participant
April 28, 2025

Thanks. I want to make it as easy as possible to distribute the utility. So I guess I will put the arrows (and style) into an AI document and distribute that with the JSX file. I don't want to run around recording arrow actions on everybody's computers.

 

The small benefit of this approach is that the artists can go in and modify the arrow in the source document whenever they want, without my help. Now I need to find out how to load an arbitrary file from the script-files location....

CarlosCanto
Community Expert
Community Expert
December 23, 2014

The scripting reference is all we've got, not everything is accessible to scripting, Arrowheads are one of the many features not exposed to scripts.

CarlosCanto
Community Expert
Community Expert
December 23, 2014

You could create your Arrowheads manually, turn them into Graphic Styles, then apply such Styles to paths using Javascript

Participating Frequently
December 24, 2014

Thanks Carlos. Adobe can be disappointing at times.

Cheers,

Brian

Sent from my iPhone