Scripts to Perform Vector Manipulations in Adobe Illustror
Please note that this page is no longer actively maintained. Hiroyuki dedicated this website to all the future updates.
This repository includes a "js" and a "jsx" folder. They are the same scripts but "js" folder includes ".js" extension and Windows newline (CRLF). Maybe suitable for old CS on Windows.
fig.1 : This script adjusts dashed lines in the selection in order to the center of the first dash comes at each anchor points.
For its purpose, when adjacent segments of an anchor of the target path have a difference in length, a rectangle like above, for example, this script splits the path at this anchor, applies a suitable dash setting for each splitted path, then put them into a group. This is a lockstep trick caused by an Illustrator path can have only one simple rule for dashes and gaps. This process also CLEARS FILL COLORS, if it needs, and if the pash has BUTT end cap, change it to PROJECTION end cap.
fig.2 : The left figure is splitted with pathfinder ( outline ), in order to make anchors at all intersection points.
adjusts the lengths of dashes and gaps of dashed lines in order to the length of the path is divisible by total length of dashes and gaps.
corrects free-hand drawn arc-like paths in the selection. To use, just select the paths and run this script.
For the (not need-to-know) detail of the method, please read the comments inside of the script with above figure.
draws an (approximated) Archimedean spiral.
draws an arrow for each selected end (anchor) of the selected paths.
"A" and "V" mean the shape of the head of the arrow. The visible peaks of arrows exactly locate at each visible end of the selected paths. The end of paths are trimmed in order to avoid sticking out from the head of the arrow. The path with projection end cap is modified to but end cap.
draws a circle with specified number of anchor points.
draws circumcircles for each selcted path
Method:
The major reason why I wrote this script is to draw a "circumcircle" for a star.
So the method to find the center and the radius for the circumcircle is rather incertitude.
The rightmost one in the figure above is a case of failure.
draws common tangents to the selected curved lines, if they are detected.
cuts selected paths at each selected anchor.
adds a new layer and draws dancing people on it
The dancers are made with various width of lines. So please remember to adjust the setting of Scale Tool for scaling strokes.
divides each selected segment into specified number based on the length.
The length of each segment is equally distributed.
duplicates the foreground object in the selection at the locations of the rest of each selected anchor points.
extends all handles of selected anchor points with specified rate.
100 : original size
120 : extend 20%
80 : shorten 20%
0 : remove handles
-100 : reverse handles
joins the open paths in the selection together with reasonable order
merges nearly overlapped anchor points.
It also reports how many anchor points had been reduced.
To use, simply select the path(es) and run this script.
creates Metaball-like shapes
Metaball-Arc uses arcs to connect. Metaball uses suitable bezier curves.
How To Use
It doesn't check in the script whether each path is really a circle. So have fun with other shapes...
Combining the shapes using Pathfinder may results several overlapping anchor points on the path. if it occurs, it may help to solve it to use my another script "Merge Overlapped Anchors.js". (See above)
finds out length of the each selected path, and total length of the selected paths. Then write out them on the artboard as text object.
This script uses JavaScript's "length" property of PathItem. if it is available (= CS3 or later). You can force calculate the length by "use_native_property" setting set to false. (See comments inside the script )
The returned values of "PathItem.length" property and the function in this script are slightly different especially in complex paths. It seems that the difference is 0.05 millimeter at most.
removes selected anchor points
reverses the order of the anchor points of each selected paths
rounds selected corners of PathItems.
Especially for the corners at the intersection point of curves, this script may work better than "Round Corners" filter, but slower.
How To Use
Illustrator CS
1. Select the anchor(s) or whole path(es) to round.
2. Run this script. A prompt box appears to set the rounding radius.
3. Input the radius in point, then click OK.
You can choose a behavior like Illustrator10 by change the setting. See "setting" section inside the script.
Illustrator 10
1. Select the anchor(s) or whole path(es) to round
A foreground path will be used to specify the rounding radius - Half width of foreground path is used for the radius, excluding stroke width. So a circle is the most suitable for intuitive understanding and ease of use. The script would ask you to choose if there's a difference greater than 1pt between width and height of foreground path.
Rounding Method
Basically, the rounding method is compatible with the "Round Corners" filter. It is to add two anchors instead of the original anchor, at the points of specified line length from each selected corner. So if there're too many anchors on original path, this script can not round nicely.
Radius
Actually, the specified "radius" is not for a radius of arcs which drawn. It is for the line length from each selected corner and is for the base to compute the length of handles. The reason calling it "radius" is for compatibility with the "Round Corners" filter.
This script does not round the corners which already rounded. For example, select a circle and run this script does nothing.
In the rounding process, the script merges anchors which when the distance between anchors is less than 0.05 points.
This script does not work for some part of compound paths. When this occurs, please select part of the compound path or release the compound path and select them, then run script again.
I still have not figured out how to get properties from grouped paths inside a compound path.
draws (approximate) sine curve at the origin of the artboard
The values of the coordinates are based on Don Lancaster's Guru's Lair Cubic Spline Library.
draws tangent lines from a selected anchor point to selected curved segments.
This script tries to find a path with only 1 anchor selected, from foreground to background. And specifies the selected point of the path as starting point of tangents.
"the selected curved segments" means the rest of the selected paths.
You can use an isolated point as the starting point. In this case, starting isolated point is removed after drawing tangents.
Drawn tangents have handles at ends. So you can move the starting side of anchor point with keeping tangency.
draws a tree-like shape at the center of the artboard
The trees are made with various width of lines. So please be careful about the setting of Scale Tool when you want to scale them.
Tested with Adobe Illustrator CS5, Windows XP SP3 (Japanese version).
Tested basic functions with CS6 tryout, Mac OS X 10.6.8 (Japanese version).
Choose File>Scripts>Browse, and open the script to run.
Or place the script in the directory "Adobe Illustrator CS3\Presets\Scripts", then restart Illustrator.
Download the PDF documents for more information.
Some scripts work only for selected anchor points or sides (= lines, bezier curve segments). A side (= a line, a bezier curve segment) means one of each line segment drawn to connect a couple of anchor points. In other words, selected parts means targets for Cut or Copy command. Regular (or Group) Select Tool selects whole of a path.
Some scripts don't work for some part of compound paths. When this occurs, please select part of the compound path or release the compound path and select them, then run script again. I still have not figured out how to get properties from grouped paths inside a compound path.
All the scripts was written to be compatible with AI 10 through CS3 (or later?). Only problem is AI 10 lacks a prompt dialog that users can specify the optional values. For now, one of the solution for this is to edit the scripts manually to change the default value of these varibles. They are most often placed in the beginning of the scripts with the appropriate comments.
The scripts are created by Hiroyuki Sato (@shspage), and uploaded on GitHub by Shanfan Huang(@shanfan).
Copyright©2013 Hiroyuki Sato
https://github.com/shspage
This script is distributed under the MIT License. See the LICENSE file on GitHub for details.
Free to use and distribute.