SetGeometry
Sets a custom geometry for the current shape.
Syntax
expression.SetGeometry(oGeometry);
expression - A variable that represents a ApiShape class.
Parameters
| Name | Required/Optional | Data type | Default | Description |
|---|---|---|---|---|
| oGeometry | Required | ApiGeometry | The geometry to set. |
Returns
boolean
Example
Creates a custom triangle shape and adds it to the worksheet.
- Code
- Result
// Applies custom geometry to a shape with specific fill and stroke.
let worksheet = Api.GetActiveSheet();
let customGeometry = Api.CreateCustomGeometry();
let path = customGeometry.AddPath();
path.SetWidth(100 * 36000);
path.SetHeight(100 * 36000);
path.SetStroke(true);
path.SetFill("norm");
path.MoveTo(50 * 36000, 0);
path.LineTo(70 * 36000, 45 * 36000);
path.LineTo(55 * 36000, 70 * 36000);
path.LineTo(100 * 36000, 100 * 36000);
path.LineTo(0, 100 * 36000);
path.Close();
let fill = Api.CreateSolidFill(Api.CreateRGBColor(100, 150, 200));
let stroke = Api.CreateStroke(18000, Api.CreateSolidFill(Api.CreateRGBColor(50, 75, 100)));
let shape = worksheet.AddShape("rect", 60 * 36000, 60 * 36000, fill, stroke, 3, 0, 2, 2);
shape.SetGeometry(customGeometry);