Home/ Reference/ Align / Distribute

shape.AlignToShape(AlignType, TargetShape)

Aligns to another object. The argument order is alignment first, target second; swap them and it fails silently.

Signature

shape.AlignToShape(AlignType, TargetShape)

Notes

Aligns to another object. The argument order is alignment first, target second; swap them and it fails silently.

Python example (runnable)

Requires pywin32. The example assumes app / doc / page / layer are already connected. See Connection & Init
Python
shapes = app.ActiveSelectionRange
if shapes.Count < 2:
    raise SystemExit("Select at least two shapes")

target = shapes.Item(1)                             # the first one is the reference
for i in range(2, shapes.Count + 1):
    shapes.Item(i).AlignToShape(4, target)          # 4 = align tops to target

print("All tops aligned to the first shape")

About this section: Align / Distribute

Align / Distribute — align, distribute and transform.

Other entries in this section