Skip to main content

GetAllShapes

Returns an array with all the shape objects from the presentation slides, excluding slide layouts and slide masters.

Syntax​

expression.GetAllShapes();

expression - A variable that represents an ApiPresentation class.

Parameters​

This method doesn't have any parameters.

Returns​

ApiShape[]

Example​

List all shapes in a presentation.

// Access every rectangle, circle, heart, or custom shape in the presentation.

// Retrieve shapes from slides and count them in a presentation.

const presentation = Api.GetPresentation();
const slide = presentation.GetSlideByIndex(0);
slide.RemoveAllObjects();

const shapeTypes = ['heart', 'rect', 'ellipse'];
for (let i = 0; i < shapeTypes.length; i++) {
const fill = Api.CreateSolidFill(Api.RGB(100 + i * 50, 150, 200));
const stroke = Api.CreateStroke(0, Api.CreateNoFill());
const shape = Api.CreateShape(shapeTypes[i], 38 * 36000, 38 * 36000, fill, stroke);
shape.SetPosition(i * 48 * 36000, 0);
slide.AddObject(shape);
}
const shapesCount = presentation.GetAllShapes().length;
const labelFill = Api.CreateSolidFill(Api.RGB(255, 230, 150));
const labelStroke = Api.CreateStroke(0, Api.CreateNoFill());
const label = Api.CreateShape('rect', 60 * 36000, 20 * 36000, labelFill, labelStroke);
label.SetPosition(0, 50 * 36000);
slide.AddObject(label);

const docContent = label.GetDocContent();
const paragraph = docContent.GetElement(0);
paragraph.AddText('Shapes in presentation excluding slide layouts and master slides: ' + shapesCount);