Skip to main content
Participant
October 1, 2019
Question

Script to create multiple circles in specific locations

  • October 1, 2019
  • 2 replies
  • 938 views

Hello all! Please forgive me if this has been asked before but I've looked all over can can't quite find what I need.  While creating signs, I often need to represent drill holes. This comes in one of two flavors: 1) a circle in each corner or 2)  a circle in the middle at the top and bottom.  All of these circles are  3/16" dia., 1" in from the edge, have have a 0.1pt thick stroke with no fill.  I realize I need two scripts but I'm very very new to scripting and could really use the help to get started. Thank you in advance for your consideration and time.   

This topic has been closed for replies.

2 replies

Inspiring
October 3, 2019

Adding to the previous reply, here is a script for doing the corners. The hard part of the script is figuring out the geometric bounds for each of the circles. Walk through the script to see how these were calculated. In point units 72 is 1 inch; 13.5 is 3/16 of an inch.

var cr; 
app.scriptPreferences.measurementUnit = MeasurementUnits.POINTS;
var docRef = app.documents[0];
var mySwatch = docRef.swatches[3];
var pageRef = docRef.pages.item(0);
var pageBounds = pageRef.bounds;
var tp = pageBounds[0];
var lf = pageBounds[1];
var bm = pageBounds[2];
var rt = pageBounds[3];
var topLeft = [tp + 72, lf + 72, tp+(72+13.5), lf+(72+13.5)];
var topRight = [tp + 72, rt - (72 +13.5), tp + (72+13.5), rt- 72];
var botLeft = [bm - (72+13.5), lf + 72, bm-72, lf + (72+13.5)];
var botRight = [bm - (72+13.5), rt - (72+13.5), bm - 72, rt - 72];
var boundsArray = [topLeft, topRight, botLeft, botRight];
for (var i = 0; i < boundsArray.length; i ++) { 
cr = pageRef.ovals.add(); //add a circle
cr.geometricBounds = boundsArray[i]; 
cr.strokeWeight = 1; //adding stroke weight in point units
cr.strokeColor = mySwatch;
}
Ten A
Community Expert
Community Expert
October 2, 2019
Generally to say, Illustrator is the better way to make signboards.
However, when drawing a circle in InDesign with JavaScript, it looks like below:
var cr = app.activeDocument.pages[0].ovals.add(); //add a circle in active documents first page
cr.geometricBounds = [10,10,100,100]; //apply geometory to the circle
cr.strokeWeight = 0.1; //adding stroke weight
cr.strokeColor = app.activeDocument.swatches[3]; //choose color from active document's swatch