Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
You could create your Arrowheads manually, turn them into Graphic Styles, then apply such Styles to paths using Javascript
Copy link to clipboard
Copied
Thanks Carlos. Adobe can be disappointing at times.
Cheers,
Brian
Sent from my iPhone
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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().
Copy link to clipboard
Copied
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....
Copy link to clipboard
Copied
// $.fileName - current script
// Script parent folder + target file name
var myFile = (new File($.fileName)).parent + "/template.ai";
app.open( new File(myFile) );
Copy link to clipboard
Copied
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.