跳到主要内容

GetGeometry

返回当前形状的几何对象。

语法

expression.GetGeometry();

expression - 表示 ApiShape 类的变量。

参数

此方法没有任何参数。

返回值

ApiGeometry

示例

读取文档中形状的几何轮廓和预设类型。

// How do I find out the exact outline definition used by a shape in a document?

// Inspect whether a shape uses a built-in or custom outline path in a document.

let doc = Api.GetDocument();
let paragraph = doc.GetElement(0);
let fill = Api.CreateSolidFill(Api.RGB(255, 200, 100));
let stroke = Api.CreateStroke(36000, Api.CreateSolidFill(Api.RGB(200, 100, 0)));
let shape = Api.CreateShape("star5", 100 * 36000, 100 * 36000, fill, stroke);
let geometry = shape.GetGeometry();
paragraph.AddText("Preset: " + geometry.GetPreset() + ", IsCustom: " + geometry.IsCustom());
paragraph.AddDrawing(shape);