首页/ 接口索引/ Shape 几何与变换

shape.CenterX / .CenterY

中心点坐标,定位对齐时比 Left/Top 好用。

签名

shape.CenterX / .CenterY

说明

中心点坐标,定位对齐时比 Left/Top 好用。

Python 示例(可直接运行)

依赖 pywin32。示例假定 app / doc / page / layer 已就绪。 见「连接与初始化」
Python
shape = app.ActiveSelectionRange(1)

# 中心点 = (左+右)/2 和 (上+下)/2,对齐时比 Left/Top 好用
print("中心 X:", (shape.Left + shape.Right) / 2)
print("中心 Y:", (shape.Top + shape.Bottom) / 2)

print("CenterX:", shape.CenterX)          # 也可以直接读
print("CenterY:", shape.CenterY)

关于本类:Shape 几何与变换

位置、尺寸、旋转、包围盒。全部跟随 doc.Unit(你的环境是英寸),字号例外。

同类其他接口