shape.Name
对象名称,读写。给关键元素起名("标题底条"、"图框")后续好找。
签名
shape.Name
说明
对象名称,读写。给关键元素起名("标题底条"、"图框")后续好找。
Python 示例(可直接运行)
Python
shape = app.ActiveSelectionRange(1)
shape.Name = "主标题" # 给对象起名,后续按名查找
print("名称:", shape.Name)
page = doc.ActivePage
for i in range(1, page.Shapes.Count + 1):
s = page.Shapes.Item(i)
if s.Name == "主标题":
print("找到了,类型:", s.Type)
关于本类:Shape 几何与变换
位置、尺寸、旋转、包围盒。全部跟随 doc.Unit(你的环境是英寸),字号例外。
- 本类共 17 条,这是其中之一。
- 完整分类见:Shape 几何与变换
同类其他接口
- shape.Left / .Top / .Right / .Bottom四边坐标。Top > Bottom(Y 轴向上)。群组内部的子对象读不到,得用 GetBoundingBox。
- shape.PositionX / .PositionY左下角坐标,直接读写比 SetPosition 少一层调用。
- shape.SizeWidth / .SizeHeight宽度 / 高度,读写。缩放时先读原尺寸再按比例算新尺寸。
- shape.CenterX / .CenterY中心点坐标,定位对齐时比 Left/Top 好用。
- shape.RotationAngle旋转角度(度),绕 RotationCenterX/Y 转。
- shape.SetPosition(x, y, anchor)移动。默认锚点是左下角,第 3 个参数可指定锚点。代码里 img.SetPosition((w - img.SizeWidth)/2, (h
- shape.SetSize(w, h, anchor)缩放,默认锚点左上。等比例缩放要自己算:s = max(W/ow, H/oh); img.SetSize(ow*s, oh*s)。
- shape.Move(dx, dy)相对位移,比 SetPosition 省一次读坐标。