Skip to main content
Kazem Rahimi
Inspiring
September 23, 2021
Question

How to Change "Align to" option with script?

  • September 23, 2021
  • 1 reply
  • 1253 views

hi everyone,

is there a way to change "align to" option with script?

i want to write code for align object with my script to Artboard or to selections....

but the Align to option the Align Palette not chaneged.

Thank for answers...

 

This topic has been closed for replies.

1 reply

Charu Rajput
Community Expert
Community Expert
September 23, 2021

Hi,

May be following link will be helpful to you

 

For Selection or key objectss

https://community.adobe.com/t5/illustrator-discussions/library-for-aligning-objects-via-script/m-p/11925954

 

For artboard

https://community.adobe.com/t5/illustrator-discussions/script-to-align-selected-objects-to-artboard/m-p/5595164

 

Not tested myself but can give you an idea. It may not able to achieve what you want to see on UI,  but ofcourse end result will be same.

Best regards
Kazem Rahimi
Inspiring
September 25, 2021

Hi.

Thanks a lot for your response.

I wire the script for aligning,

the problem is that this method work well in the case that selected one object or one group,

but when I select an cliped mask object or group that has clip mask and etc dont work corectly,

 

use of align panel of Illustrator dont this problem. you can use align for objec or group that inside of many clip mask or etc.

my solution is that use an Action for the align object, and call the Action from a UI dialog and command button.

every thing is ok. but new problem is that i can not change the "Align to" option from my dialog....

thanks again.

best regards.

 

Disposition_Dev
Legend
October 14, 2021

Ah, gotcha... The updated version seems to work on this case too. I'm sure there are so many other weird cases that'll break it, just glad I could fix a few this go-round. Thanks again for the heads up!


Gah, i'm a goof. first time i looked at your code, i found an issue. then when you fixed it, and i went back looking at it, i didn't see the issue anymore. then you merged to main and i saw the issue again. haha. I made a pull request with the proposed fixes. The issue was inside your clip mask condition. If the object was a clip group, you checked to see whether the top level element was a compound path, then if it was you tried to access the pathItems[0] element. this is where you'll get the runtime error if you have a compound clipping path like i described yesterday.

 

here's an edited version of your hot_mess.ai file which contains the kind of artwork i'm talking about.

https://drive.google.com/file/d/1VD3bu7tNlycPSqpEOZw3qmN5u3mYcvxz/view?usp=sharing