跳到主要内容

GetX

返回“moveTo”/“lineTo”路径命令的 X 坐标。

语法

expression.GetX();

expression - 表示 ApiPathCommand 类的变量。

参数

此方法没有任何参数。

返回值

string | null

示例

读取路径命令端点的水平位置并在电子表格中显示。

// How do I find the X coordinate of a drawing command on a shape in a spreadsheet?

// Confirm where a path step lands horizontally within a shape's drawing area in a spreadsheet.

let worksheet = Api.GetActiveSheet();
let fill = Api.CreateSolidFill(Api.RGB(100, 150, 200));
let stroke = Api.CreateStroke(18000, Api.CreateSolidFill(Api.RGB(50, 75, 100)));
let shape = worksheet.AddShape("star5", 60 * 36000, 60 * 36000, fill, stroke, 3, 0, 2, 0);
let geometry = shape.GetGeometry();
let path = geometry.GetPath(0);
let commands = path.GetCommands();
worksheet.GetRange("A8").SetValue("Commands: " + path.GetCommandCount());
let cmd = path.GetCommand(0);
worksheet.GetRange("A9").SetValue("Type: " + cmd.GetType() + " at (" + cmd.GetX() + ", " + cmd.GetY() + ")");