shape.Type
形状类型。1 矩形 / 2 椭圆 / 3 曲线 / 5 位图 / 6 文字 / 7 群组。转曲后类型会从 6 变成 3(或 7)。
签名
shape.Type
说明
形状类型。1 矩形 / 2 椭圆 / 3 曲线 / 5 位图 / 6 文字 / 7 群组。转曲后类型会从 6 变成 3(或 7)。
Python 示例(可直接运行)
Python
shape = app.ActiveSelectionRange(1)
t = shape.Type
names = {1: "矩形", 2: "椭圆", 3: "曲线", 4: "多边形",
5: "位图", 6: "文字", 7: "群组", 8: "选区"}
print("类型代号:", t, "→", names.get(t, "其他"))
if t == 6: # 只有文字才能访问 .Text
print("文字内容:", shape.Text.Contents)
关于本类: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 省一次读坐标。