• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

How to make scripts for aligning objects?

Contributor ,
Mar 09, 2016 Mar 09, 2016

Copy link to clipboard

Copied

Hey,

How would I proceed to create scripts for aligning objects? Basically what I want is to keybind the buttons for the Horizontal and Vertical align -icons.

In Photoshop you can use the ScriptListener but there doesn't seem to be anything like it for Illustrator. Illustrator also seems to have a totally different scripting structur!? I tried running a Photoshop script in Illustrator and it complains about charIDToTypeID() and stringIDToTypeID() not being valid functions.

TOPICS
Scripting

Views

1.4K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Community Expert ,
Mar 09, 2016 Mar 09, 2016

Copy link to clipboard

Copied

Here is a sample solution of align objects:

var refBnds = app.activeDocument.selection[0].geometricBounds;

var tg = app.activeDocument.selection[1];

var ct = refBnds[0] + (refBnds[2] - refBnds[0]) / 2;

var md = refBnds[1] + (refBnds[3] - refBnds[1]) / 2;

var wd = tg.width;

var ht = tg.height;

tg.position = [ct - wd / 2, md + ht / 2];

There are big difference between PS and  AI. You can read references below:

http://www.adobe.com/devnet/illustrator/scripting.html

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Mar 09, 2016 Mar 09, 2016

Copy link to clipboard

Copied

you can record actions for align.
this gives them a keyboard shortcut.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Mar 17, 2016 Mar 17, 2016

Copy link to clipboard

Copied

True. Downside is that you can only keybind to the function buttons F1-F12.

But then I realized that Illustrator is really stupid in this sense because compared to Photoshop, you cannot assign keybinds to custom scripts anyway! -_-

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Mar 21, 2016 Mar 21, 2016

Copy link to clipboard

Copied

LATEST

This is a point of frustration for nearly all of us here.
you can add a script to an action then keybind that action.

but is will not be persistent on restart.

you might be best with an addon to run scripts.

Script bay works well,

Ten-A has written one that I have still yet to test, sorry Ten-A.

and silly-V also has a good script that can manage your script running.

let me know if you need me to find the links to any of those

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines