GetCommand
Returns a specific path command by its index.
Syntax
expression.GetCommand(nIndex);
expression - A variable that represents a ApiPath class.
Parameters
| Name | Required/Optional | Data type | Default | Description |
|---|---|---|---|---|
| nIndex | Required | number | The path command index. |
Returns
ApiPathCommand | null
Example
Analyzes path commands of a star shape on a presentation slide.
- Code
- Result
// Shows command count and first command details in a text shape.
let presentation = Api.GetPresentation();
let slide = presentation.GetSlideByIndex(0);
let fill = Api.CreateSolidFill(Api.CreateRGBColor(100, 150, 200));
let stroke = Api.CreateStroke(36000, Api.CreateSolidFill(Api.CreateRGBColor(50, 75, 100)));
let shape = Api.CreateShape("star5", 100 * 36000, 100 * 36000, fill, stroke);
let geometry = shape.GetGeometry();
let path = geometry.GetPath(0);
let commands = path.GetCommands();
let cmd = path.GetCommand(0);
let paragraph = shape.GetDocContent().GetElement(0);
paragraph.AddText("Commands: " + path.GetCommandCount());
paragraph.AddText(", First: " + cmd.GetType() + " at (" + cmd.GetX() + ", " + cmd.GetY() + ")");
shape.SetPosition(1000000, 1000000);
slide.AddObject(shape);