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.
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:
Copy link to clipboard
Copied
you can record actions for align.
this gives them a keyboard shortcut.
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! -_-
Copy link to clipboard
Copied
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