This Adobe Illustrator script creates a smooth arc with a specified number of anchor points. It features an integrated ScriptUI dialog that allows users to input parameters such as the number of anchor points, radius, start angle, and end angle. The script centers the arc within the active document’s artboard and calculates smooth in/out handles for each anchor point, ensuring a high-quality smooth curve. It’s ideal for designers looking to automate the process of drawing precise and aesthetically pleasing arcs.

Usage:
- Open Adobe Illustrator and ensure an active document/artboard is available.
- Run the script.
- In the dialog window that appears, enter the desired values for the number of anchor points (minimum 2), radius, start angle (in degrees), and end angle (in degrees).
- Click “OK” to generate the arc. The arc will be drawn centered on the active artboard.

Illustrator Extendscript
// Script to create a smooth arc with a specified number of anchor points and integrated UI options, centered in the document.
function drawSmoothArc(numAnchors, radius, startAngle, endAngle) {
if (numAnchors < 2) {
alert("Please specify at least 2 anchor points for a smooth arc.");
return;
}
// Convert start and end angles from degrees to radians
var startRad = startAngle * Math.PI / 180;
var endRad = endAngle * Math.PI / 180;
var arcAngle = endRad - startRad;
// Get the active document and artboard dimensions for centering the arc.
var doc = app.activeDocument;
var activeAB = doc.artboards[doc.artboards.getActiveArtboardIndex()];
var abRect = activeAB.artboardRect; // [left, top, right, bottom]
var centerX = (abRect[0] + abRect[2]) / 2;
var centerY = (abRect[1] + abRect[3]) / 2;
// Calculate handle length dynamically based on the arc segment
var theta = arcAngle / (numAnchors - 1); // Angle step between points
var handleLength = radius * 4 / 3 * (1 - Math.cos(theta / 2)) / Math.sin(theta / 2);
// Start a new document if no document is open
if (app.documents.length === 0) {
doc = app.documents.add();
// Recalculate center after creating a new document using default artboard
activeAB = doc.artboards[doc.artboards.getActiveArtboardIndex()];
abRect = activeAB.artboardRect;
centerX = (abRect[0] + abRect[2]) / 2;
centerY = (abRect[1] + abRect[3]) / 2;
}
// Create a new layer for the arc
var arcLayer = doc.layers.add();
arcLayer.name = "Smooth Arc";
// Create a new path for the arc
var arcPath = arcLayer.pathItems.add();
arcPath.stroked = true;
arcPath.strokeColor = new RGBColor();
arcPath.strokeColor.red = 0;
arcPath.strokeColor.green = 0;
arcPath.strokeColor.blue = 0;
arcPath.filled = false;
// Calculate and add each anchor point along the arc
for (var i = 0; i < numAnchors; i++) {
var angle = startRad + i * theta;
// Anchor point position
var x = centerX + radius * Math.cos(angle);
var y = centerY + radius * Math.sin(angle);
// In and out handles for smoothness
var inHandleX = x - handleLength * Math.cos(angle + Math.PI / 2);
var inHandleY = y - handleLength * Math.sin(angle + Math.PI / 2);
var outHandleX = x + handleLength * Math.cos(angle + Math.PI / 2);
var outHandleY = y + handleLength * Math.sin(angle + Math.PI / 2);
// Add anchor point with handles
var point = arcPath.pathPoints.add();
point.anchor = [x, y];
point.leftDirection = [inHandleX, inHandleY];
point.rightDirection = [outHandleX, outHandleY];
point.pointType = PointType.SMOOTH;
}
// Ensure the arc is open by not setting it as closed
arcPath.closed = false;
}
function showUIDialog() {
// Create a new dialog window
var dlg = new Window('dialog', 'Draw Smooth Arc');
dlg.alignChildren = 'fill';
// Panel for input settings
var inputPanel = dlg.add('panel', undefined, 'Settings');
inputPanel.orientation = 'column';
inputPanel.alignChildren = 'left';
inputPanel.margins = 15;
// Number of Anchor Points
inputPanel.add('statictext', undefined, 'Number of Anchor Points:');
var numAnchorsInput = inputPanel.add('edittext', undefined, '6');
numAnchorsInput.characters = 10;
// Radius
inputPanel.add('statictext', undefined, 'Radius:');
var radiusInput = inputPanel.add('edittext', undefined, '100');
radiusInput.characters = 10;
// Start Angle
inputPanel.add('statictext', undefined, 'Start Angle (degrees):');
var startAngleInput = inputPanel.add('edittext', undefined, '0');
startAngleInput.characters = 10;
// End Angle
inputPanel.add('statictext', undefined, 'End Angle (degrees):');
var endAngleInput = inputPanel.add('edittext', undefined, '180');
endAngleInput.characters = 10;
// Button Group
var btnGroup = dlg.add('group');
btnGroup.alignment = 'center';
var okBtn = btnGroup.add('button', undefined, 'OK', {name:'ok'});
var cancelBtn = btnGroup.add('button', undefined, 'Cancel', {name:'cancel'});
// On OK button click
okBtn.onClick = function() {
// Parse input values to numbers
var numAnchors = parseInt(numAnchorsInput.text, 10);
var radius = parseFloat(radiusInput.text);
var startAngle = parseFloat(startAngleInput.text);
var endAngle = parseFloat(endAngleInput.text);
if (isNaN(numAnchors) || numAnchors < 2) {
alert("Please enter a valid number for anchor points (at least 2).");
return;
}
if (isNaN(radius) || radius <= 0) {
alert("Please enter a valid positive number for radius.");
return;
}
if (isNaN(startAngle) || isNaN(endAngle)) {
alert("Please enter valid numbers for angles.");
return;
}
dlg.close();
drawSmoothArc(numAnchors, radius, startAngle, endAngle);
};
// Cancel button to close the dialog without running the script
cancelBtn.onClick = function() {
dlg.close();
};
dlg.center();
dlg.show();
}
// Run the UI dialog
showUIDialog();