This quick guide describes how to merge shapes in PowerPoint using Python. It covers setting up an IDE, a list of programming steps, and sample code to combine two shapes in PowerPoint using Python. The guide also provides options for creating a custom PPTX/PPT with a merged shape to meet your requirements.
Steps to Combine Shapes in PPT using Python
- Set the environment to use Aspose.Slides for Python via .NET to merge shapes
- Create a new presentation and open the first default slide in it
- Add sample shapes in the slide that overlap each other
- Calculate the dimensions of a box that fits around all the target shapes to be merged
- Add a new shape similar in size to the box for holding all the shapes in it
- Copy the outline of each source shape and move it to its respective place inside the new shape
- Set the new shape’s geometry using the copied outlines together
- Customize the merged shape by setting a solid color, removing its border, and adding a text label
- Delete the original shapes from the slides and save the presentation
These steps explain how to combine shapes in PowerPoint using Python. Create a new presentation, open the first slide, add sample overlapping shapes, calculate the bounding box around the target shapes, add a new shape with a similar size to the defined box, and copy the outline of each source shape within the newly added shape. Combine the copied outlines to define the new shape’s geometry, set the merged shape’s properties as needed, and delete the original shapes before saving the presentation.
Code to Combine Two Shapes to Make a New Shape using Python
This code demonstrates how to merge shapes on PowerPoint using Python. A shape’s geometry doesn’t store its rotation, so if a shape is rotated, apply its rotation value to its path before merging. Use the shapes’ visual bounds instead of their frame size for a tighter bounding box, hide the inner outlines of the source shapes for better visibility, and keep the original styling to preserve the source shapes’ look.
This article teaches how to merge shapes. To draw various types of shapes, refer to the article Draw Shapes in PowerPoint using Python.