ShapeCollection is the container for all shapes on a slide. Access it via slide.shapes. It provides factory methods to add every supported shape type and collection methods to iterate, index, remove, or reorder shapes.
Package: aspose.slides_foss
ShapeCollection
Access via slide.shapes.
Add Methods
| Method | Signature | Returns | Description |
|---|
add_auto_shape | add_auto_shape(shape_type, x, y, width, height[, create_from_template=True]) -> AutoShape | AutoShape | Add a standard geometric shape at the given position and size (all in points). |
insert_auto_shape | insert_auto_shape(index, shape_type, x, y, width, height[, create_from_template=True]) -> AutoShape | AutoShape | Insert an AutoShape at a specific zero-based position in the collection. |
add_connector | add_connector(shape_type, x, y, width, height[, create_from_template=True]) -> Connector | Connector | Add a line connector. Use ShapeType.STRAIGHT_CONNECTOR1, BENT_CONNECTOR3, etc. |
insert_connector | insert_connector(index, shape_type, x, y, width, height[, create_from_template=True]) -> Connector | Connector | Insert a connector at a specific position. |
add_picture_frame | add_picture_frame(shape_type, x, y, width, height, image) -> PictureFrame | PictureFrame | Add a picture frame. image must be a PPImage obtained from prs.images.add_image(...). |
insert_picture_frame | insert_picture_frame(index, shape_type, x, y, width, height, image) -> PictureFrame | PictureFrame | Insert a picture frame at a specific position. |
add_table | add_table(x, y, column_widths, row_heights) -> Table | Table | Add a table. column_widths and row_heights are lists of floats in points. |
insert_table | insert_table(index, x, y, column_widths, row_heights) -> Table | Table | Insert a table at a specific position. |
Remove and Reorder Methods
| Method | Signature | Description |
|---|
remove | remove(shape) | Remove the given shape object from the collection. |
remove_at | remove_at(index) | Remove the shape at the given zero-based index. |
clear | clear() | Remove all shapes from the slide. |
reorder | reorder(new_index, shape_or_shapes) | Move one shape or a list of shapes to a new zero-based index (affects z-order). |
Query Methods
| Method | Signature | Description |
|---|
index_of | index_of(shape) -> int | Return the zero-based index of a shape, or -1 if not found. |
to_array | to_array() -> list[Shape] | Return all shapes as a Python list. |
to_array | to_array(start, count) -> list[Shape] | Return a slice of count shapes starting at start. |
Collection Protocol
| Member | Description |
|---|
__getitem__(i) | Return the shape at index i. Negative indices supported. |
__len__ | Number of shapes on the slide. |
__iter__ | Iterate shapes in z-order (bottom to top). |
Properties
| Property | Type | Description |
|---|
parent_group | GroupShape or None | Parent group shape, or None for slide-level collections. |
AutoShape
The most common shape type. Created by add_auto_shape().
Properties
| Property | Type | Description |
|---|
shape_type | ShapeType | The geometry preset (e.g. RECTANGLE, ELLIPSE, TRIANGLE). |
text_frame | TextFrame or None | The attached text container. None until add_text_frame() is called. |
fill_format | FillFormat | Shape fill settings. |
line_format | LineFormat | Shape border settings. |
effect_format | EffectFormat | Visual effects (shadow, glow, blur). |
three_d_format | ThreeDFormat | 3D bevel and extrusion settings. |
x, y | float | Position in points. |
width, height | float | Size in points. |
name | str | Shape name as shown in the Selection Pane. |
hidden | bool | Whether the shape is hidden. |
rotation | float | Clockwise rotation in degrees. |
z_order_position | int | Index in the z-order stack. |
Methods
| Method | Signature | Description |
|---|
add_text_frame | add_text_frame(text) -> TextFrame | Create a text frame with the given initial text, or return the existing one. |
PictureFrame
A shape containing an embedded raster image. Created by add_picture_frame().
Properties
| Property | Type | Description |
|---|
picture_format | IPictureFillFormat | Access the embedded image and crop settings. |
fill_format | FillFormat | Frame background fill (usually inherits the picture). |
line_format | LineFormat | Frame border. |
Inherits all position, size, and effect properties from Shape.
Typical workflow
Connector
A line shape that can link two anchor shapes. Created by add_connector().
Properties
| Property | Type | Description |
|---|
line_format | LineFormat | Stroke appearance (colour, width, arrowheads). |
start_shape_connected_to | IShape or None | Shape at the start end of the connector. |
end_shape_connected_to | IShape or None | Shape at the end of the connector. |
start_shape_connection_site_index | int | Connection site index on the start shape. |
end_shape_connection_site_index | int | Connection site index on the end shape. |
Common connector ShapeType values
| Constant | Description |
|---|
ShapeType.STRAIGHT_CONNECTOR1 | Straight line |
ShapeType.BENT_CONNECTOR2 | One elbow |
ShapeType.BENT_CONNECTOR3 | Two elbows (most common) |
ShapeType.CURVED_CONNECTOR3 | Curved with midpoint handle |
GroupShape
A shape that contains other shapes. Created when the source file has grouped objects.
Properties
| Property | Type | Description |
|---|
shapes | ShapeCollection | The nested collection of grouped shapes. |
Iterating a GroupShape.shapes follows the same API as the slide-level ShapeCollection.
Usage Example
Add shapes, a picture, and a connector
See Also