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

How to align object vertically on the artboard via script?

Explorer ,
Oct 27, 2022 Oct 27, 2022

Copy link to clipboard

Copied

How to align object vertically on the artboard via script?

For example, there is a group

 

 

var smallCircleGroup = doc.groupItems.add();
// adding some objects to the group

 

 

Now I woud like to align the group vertically on the artboard as it would be done by `Vertical Align Center` Illustrator's command. Is there a script ecvivalent for the command to do that?

TOPICS
Scripting

Views

70

Likes

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

correct answers 1 Correct answer

Advisor , Oct 27, 2022 Oct 27, 2022
var ABR = app.activeDocument.artboards[0].artboardRect;
var ABVerticalCentre = (ABR[3] - ABR[1]) / 2;
var bounds = smallCircleGroup.controlBounds;
smallCircleGroup.top = ABVerticalCentre - ((bounds[3] - bounds[1]) / 2);

Likes

Translate

Translate
Advisor ,
Oct 27, 2022 Oct 27, 2022

Copy link to clipboard

Copied

LATEST
var ABR = app.activeDocument.artboards[0].artboardRect;
var ABVerticalCentre = (ABR[3] - ABR[1]) / 2;
var bounds = smallCircleGroup.controlBounds;
smallCircleGroup.top = ABVerticalCentre - ((bounds[3] - bounds[1]) / 2);

Likes

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