Skip to main content

CreateShape

Creates a shape with the parameters specified.

Syntax

expression.CreateShape(shapeType, width, height, fill, stroke);

expression - A variable that represents a Api class.

Parameters

NameRequired/OptionalData typeDefaultDescription
shapeTypeOptionalShapeType"rect"The shape type which specifies the preset shape geometry.
widthOptionalEMU914400The shape width in English measure units.
heightOptionalEMU914400The shape height in English measure units.
fillOptionalApiFillApi.CreateNoFill()The color or pattern used to fill the shape.
strokeOptionalApiStrokeApi.CreateStroke(0, Api.CreateNoFill())The stroke used to create the element shadow.

Returns

ApiShape

Example

Create a shape using the 'rect' preset in a document.

// Create the "rect" shape and add it to the first paraghraph of the document.

// How to create the shape object and add it to the paragraph class in a document.

let doc = Api.GetDocument();
let paragraph = doc.GetElement(0);
let gs1 = Api.CreateGradientStop(Api.RGB(255, 213, 191), 0);
let gs2 = Api.CreateGradientStop(Api.RGB(255, 111, 61), 100000);
let fill = Api.CreateLinearGradientFill([gs1, gs2], 5400000);
let stroke = Api.CreateStroke(0, Api.CreateNoFill());
let shape = Api.CreateShape("rect", 5930900, 395605, fill, stroke);
paragraph.AddDrawing(shape);