首页/ 接口索引/ 对齐 / 分布 / 变换

shape.AlignToShape(AlignType, TargetShape)

对齐到另一个对象。注意参数顺序是先对齐方式、后目标对象,写反了会静默失败。

签名

shape.AlignToShape(AlignType, TargetShape)

说明

对齐到另一个对象。注意参数顺序是先对齐方式、后目标对象,写反了会静默失败。

Python 示例(可直接运行)

依赖 pywin32。示例假定 app / doc / page / layer 已就绪。 见「连接与初始化」
Python
shapes = app.ActiveSelectionRange
if shapes.Count < 2:
    raise SystemExit("请至少选中两个对象")

target = shapes.Item(1)                             # 以第一个为基准
for i in range(2, shapes.Count + 1):
    shapes.Item(i).AlignToShape(4, target)          # 4 = 顶部对齐到 target

print("已全部顶对齐到第 1 个对象")

关于本类:对齐 / 分布 / 变换

对齐参数是整数枚举(Python 里没有 cdrAlignLeft 这种常量):1 左 / 2 右 / 3 水平居中 / 4 上 / 8 下 / 12 垂直居中。可以相加组合,比如 1+4 = 左上角。

同类其他接口