Home/ Reference/ Group / Order / Boolean

shape.AlignToShape(type, other)

Aligns to another shape. In the code, title_text.AlignToShape(-1, in_rectangle); -1 centers on both axes.

Signature

shape.AlignToShape(type, other)

Notes

Aligns to another shape. In the code, title_text.AlignToShape(-1, in_rectangle); -1 centers on both axes.

Python example (runnable)

Requires pywin32. The example assumes app / doc / page / layer are already connected. See Connection & Init
Python
# centre the headline on the blue bar, both axes
page  = doc.ActivePage
layer = page.ActiveLayer

bar = layer.CreateRectangle2(0, 200/25.4, 200/25.4, 30/25.4)      # the bar
txt = layer.CreateArtisticText(10/25.4, 210/25.4, "Headline", 0, -1,
                               "Source Han Sans Bold", 36, 0, 0, 0, 3)    # the text

txt.AlignToShape(-1, bar)      # -1 = centre on both axes, relative to bar
print("Text centred on the bar")

About this section: Group / Order / Boolean

Group / Order / Boolean — grouping, ordering and boolean operations.

Other entries in this section