Skip to main content
Participant
May 4, 2024
Question

object aligin to artboard, by java script in illustrator

  • May 4, 2024
  • 3 replies
  • 376 views

need object aligin to artboard, by java script in illustrator

This topic has been closed for replies.

3 replies

Kazem Rahimi
Inspiring
May 5, 2024

Hello,

I decided to write some code for  aligning objects a few years ago,  after some try and tesing, I encountered a problem with "Nested Objets" and "clip masked" objects that was a trouble.

finally I decided to use Action and Scripts in combination! and result was acceptable.

with a panel and some conrol buttons I manipulate the proper actions.

this is my "Easy Align"  panel for Adobe Illustrator:

Sergey Osokin
Inspiring
May 5, 2024
femkeblanco
Legend
May 4, 2024
// select an object
var doc = app.activeDocument;
var ABR = doc.artboards[doc.artboards.getActiveArtboardIndex()].artboardRect;
doc.selection[0].position = [
    (ABR[0] + ((ABR[2] - ABR[0]) / 2)) - (doc.selection[0].width / 2), 
    (ABR[1] + ((ABR[3] - ABR[1]) / 2)) + (doc.selection[0].height / 2)
];