# Align
The Align
method is for aligning items, to each other, a key artwork or an artboard.
# Basic Align operations
For basic align operations, like you can do using the align panel, you simply specify the align
property. In addition to left
, right
, top
, bottom
, and center
you can align to the four corner points, topLeft
, topRight
, bottomLeft
and bottomRight
. To center items just horizontally or vertically, set the direction
property to h
or v
.
# Align to Artboard
To align to an artboard, set either the case sensitive artboardName
or the artboardNumber
properties.
# Align to a Key Art
To align to a key art, set a keyArt
search string. The key art will maintain its position and the other items will align to it.
You can set the keyArtAnchorPoint
to specify where on the key art you want to align to.
For example, if you set the keyArt
to square
, the keyArtAnchorPoint
to top
, the tagSearch
to triangle
and the align
property to bottom
it would center align the bottom of the triangle to the top of the square.
# Offset Align
In addition to aligning artworks to a given artwork or artboard, you can offset that alignment.
See the screenshot of the colored Darty logos.
They are all left aligned to the dashed axis at the bottom of the image.
The red logo does not have an offset applied to it.
The purple logo has an absoluteOffset
of 100px
applied to it, the logo's left side is 100px offset from the left side of the axis.
Both the orange and green logos have a 100
percent relativeOffset
applied to them.
The orange logo is entirely included within the axis line because the inclusive
property was not set to false
.
The green logo is entirely outside the axis because inclusive
was set to false
and the offset was set to 100
percent.
See the sample spreadsheet below for how you can set these properties.
Align Panel
Offset Align align: left
keyArt: line
red: no offset set
purple: absoluteOffset: 100px
orange: relativeOffset: 100
include: true
< br>
green: relativeOffset: 100
include: false
# Preview Bounds
The usePreviewBounds
property is used to determine whether to use the preview bounds which include the artwork's stroke width and effect dimentions or the artwork's geometric bounds which do not. The default setting should match the "User Preview Bounds" value in your Illustrator General Settings.
Before Align
After AlignkeyArt: line
usePreviewBounds: false
After AlignkeyArt: line
usePreviewBounds: true
# Align Properties
Property | Description |
---|---|
offset / absOffset / absoluteOffset | The offset of the items from the targeted item. For example, if you want to align all the cats 4cm away from the dog you would set the offset to 4cm Example Values: 100 , 2" , 1mm etc. |
alignment / align / anchorPoint | The direction to align to. If used without setting other parameters, acts the same as clicking the icons on the Align panel. If set to left it will left align the items, etc.If set to bottomRight it will align the items to their bottom right corner, as they would if one click on the bottom and then left align icons on the align panel. If set to center you it will center both horizontally and vertically 🤞, to center just horizontally or vertically, set the direction property to h or v .Valid Values: tl topLeft 1 , t top 2 , tr topRight 3 l left 4 , c center 5 , r right 6 bl bottomLeft 7 , b bottom 8 , br bottomRight 9 |
artboardName / artboard / name | The items will be align to the named artboard. The name is case sensitive. If no artboard exists with the given name, the items will be aligned to the active artboard Example Values: Artboard 1 , Sky |
artboardNumber / number | The items will be aligned to the artboard of the given 1 based index. If no artboard exists with the index, the items will not be align. Example Values: 1 , 2 |
direction | The direction to align the items. In most cases it does not need to be set as it will be inferred from the alignment, for example left will default to a horizontal direction and top to a vertical direction. It needs to be used for center to limit the direction to horizontal or vertical or to override a default direction.Valid Values: h horizontal , v vertical , hv vh horizontalVertical verticalHorizontal |
inclusive | Whether the entire artwork should be included within the relative offset. Valid Values: true (default), false |
keyart / key / target | The tag search of the item that the other items will be align to, it's own position will not change. Example Values: cow , cat , dog |
keyArtAnchorPoint / keyAnchorPoint / targetAnchorPoint | The anchor point of the item that the other items should be aligned to. Valid Values: tl topLeft 1 , t top 2 , tr topRight 3 l left 4 , c center 5 , r right 6 bl bottomLeft 7 , b bottom 8 , br bottomRight 9 |
relOffset / relativeOffset | The percentage that the item should be moved from relative to the target item. See inclusive above. |
skip | skip is a generic property for all methods, when set to true, the method will be skipped. See * and Skip for details. Valid Values: true or false |
tagSearch | The tag search of the items to align |
usePreviewBounds | Whether to use the preview bounds which include the artwork's stroke width and effect dimentions or the artwork's geometric bounds which do not. Valid Values: true , false |
# Sample Align Spreadsheet
# align-offset.xlsx
dartyLogo | |||||||
align | |||||||
align | tagSearch | keyArt | artboardNumber | targetAnchorPoint | absoluteOffset | relativeOffset | inclusive |
left | |||||||
right | redLogo | axis | |||||
left | purpleLogo | axis | 20px | ||||
left | orangeLogo | axis | 100 | TRUE | |||
left | orangeLogo | axis | 100 | FALSE | |||
left | orangeLogo | axis | 0 | TRUE | |||
left | orangeLogo | axis | 0 | FALSE | |||
bottom | 1 | bottom | |||||
right | 1 | left | |||||
bl |