Skip to main content
Sparth369
Known Participant
December 16, 2015
Question

Script - Create a small circle at the corner of the artboard

  • December 16, 2015
  • 1 reply
  • 5973 views

Can someone help me or guide me to the right direction of how to do this?

Basically, this is what I want the script to do

1. Make artboard the size of my selected artwork + 1" offset

2. Create a circle at each of the corner of the artboard

I figured out the script for #1 but I can't find figure out #2. Could anyone help?

Thanks in advance

This topic has been closed for replies.

1 reply

Silly-V
Legend
December 16, 2015

Wherever you want to put a circle, use the document.pathItems.ellipse() function. Into this function you pass 4 numbers separated by commas, the 1st 2 numbers are the top and the left coordinates, while the next 2 are width and height, respectively.

One such examples is:
var doc = app.activeDocument;

var newCircle = doc.pathItems.ellipse(0,0,10,10);

It creates a 10-diameter circle with the top/left of its bounding box at 0,0

For me it produced the following result:

Sparth369
Sparth369Author
Known Participant
December 16, 2015

‌i just figured out that part but now how do I make it align to top right based on my artboard size?

Silly-V
Legend
December 16, 2015

Okay, to make the circle around corners of your artboard, you have to get into the artboardRect property of the given artboard.

This code will get your active artboard's rectangle bounding box, its artboardRect, and stick the circle so it's top-left coordinate is at the top-right coordinate of the artboard. To put the circle so it's center is at the coordinate vs the top/left, the top/left parameters for the ellipse command have to be offset with half the width & height of the circle.

    var doc = app.activeDocument;

    var activeArtboard = doc.artboards[doc.artboards.getActiveArtboardIndex()];

    var artboardTop = activeArtboard.artboardRect[1];

    var artboardRight = activeArtboard.artboardRect[2];

    var newCircle = doc.pathItems.ellipse(artboardTop, artboardRight, 10, 10);