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
  • 6109 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?

Sparth369
Sparth369Author
Known Participant
December 17, 2015

Glad to help! Very nice to help someone get started! If all goes well, you will gain great skill and proficiency in the wonderful world of Illustrator scripting. Then, if it really takes off for you, you may notice some small changes in lifestyle such as a shift from relationships with friends and family, to extended scripting sessions in the depths of the night. That's okay, because the great realization that scripting is all, and all that matters, will gradually take over and you will become one with the script, a living extension of the computer, sent to do its bidding. Oh, sorry, got carried away there, in deep thought again.

Well Cheers!


Sorry to bother you again. Can you explain the code I have below, I thought I understood them but I am doing something wrong here

var doc = app.activeDocument; 

// Get the active Artboard index

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

// Get Artboard Top Left location

var artboardTopLeft = activeArtboard.artboardRect[1];

// Get Artboard Top Right location

var artboardTopRight = activeArtboard.artboardRect[2];

// Get Artboard Bottom Left location

var artboardBottomLeft = activeArtboard.artboardRect[3];

//Get Artboard Bottom Right location

var artboardBottomRight = activeArtboard.artboardRect[4];

// Create a circle and place it Top Leftlocation inside the artboard

var newCircle = doc.pathItems.ellipse(artboardTopLeft, artboardBottomRight-18, 18,18);

// Create a circle and place it Top Right location inside the artboard

var newCircle = doc.pathItems.ellipse(artboardTopLeft, artboardTopRight-18, 18,18);

// Create a circle and place it Bottom Right location inside the artboard

// Create a circle and place it Bottom Left location inside the artboard