Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
1

Script path arrows

Explorer ,
Dec 23, 2014 Dec 23, 2014

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.

TOPICS
Scripting
2.0K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Community Expert ,
Dec 23, 2014 Dec 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 23, 2014 Dec 23, 2014

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Dec 24, 2014 Dec 24, 2014

Thanks Carlos. Adobe can be disappointing at times.

Cheers,

Brian

Sent from my iPhone

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 25, 2025 Apr 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Apr 27, 2025 Apr 27, 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().

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 28, 2025 Apr 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....

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Apr 28, 2025 Apr 28, 2025
// $.fileName - current script
// Script parent folder + target file name
var myFile = (new File($.fileName)).parent + "/template.ai";
app.open( new File(myFile) );
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 28, 2025 Apr 28, 2025
LATEST

Thanks! I ended up adding a File-open dialog so the user can put the source file anywhere he wants. It's only used once to extract the necessary graphic style. But I might switch to this method. We'll see.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines