Adobe Illustrator Script: Add Circles to Path Points
Description
This Adobe Illustrator script adds small circles to each anchor point of the selected paths. If no document is open, it creates a new document. The script requires at least one path to be selected to run.

Usage
- Open Adobe Illustrator.
- Create or open a document.
- Select at least one path item in the document.
- Run the script.
Script Details
- Document Check:
- If there are no open documents, the script creates a new document.
- Selection Check:
- If no path items are selected, an alert message is displayed, and the script stops.
- Circle Properties:
- Each circle has a radius of 2.5 units.
- The fill color of the circles is set to RGB (255, 100, 100).
- Path Points:
- The script iterates through each selected path item.
- For each path point, a circle is created.
- The circle is placed at the location of the path point and added to a new group item within the path item’s parent.
- Locked Paths:
- Locked paths are not modified by the script.
Example
To use the script, follow these steps:
- Open or create a document in Adobe Illustrator.
- Draw or select a path.
- Run the script to add circles to each anchor point of the path.
JavaScript
(function() {
if (app.documents.length <= 0) {
app.documents.add();
}
if (selection.length <= 0) {
alert([
'You must select at least one path in',
'order to run this script.'
].join(' '));
return;
}
var radius = 2.5;
var fill = new RGBColor();
fill.red = '255';
fill.green = '100';
fill.blue = '100';
for (var i = 0; i < selection.length; i++) {
var item = selection[i];
if (!(/pathitem/i.test(item.typename))) {
continue;
}
if (!item.editable) {
// Don't modify locked paths
continue;
}
var points = item.pathPoints;
var group = item.parent.groupItems.add();
for (var j = 0; j < points.length; j++) {
var point = points[j];
var x = point.anchor[0];
var y = point.anchor[1];
var top = y + radius;
var left = x - radius;
var width = height = radius * 2;
var circle = group.pathItems.ellipse(top, left, width, height);
circle.fillColor = fill;
circle.stroked = false;
}
}
})();