insert_group_shape method

insert_group_shape(shapes)

Groups the shapes passed as a parameter into a new GroupShape node which is inserted into the current position.

def insert_group_shape(self, shapes: List[aspose.words.drawing.Shape]):
    ...
ParameterTypeDescription
shapesList[Shape]The list of shapes to be grouped.

Remarks

The position and dimension of the new GroupShape will be calculated automatically.

VML and DML shapes cannot be grouped together.

insert_group_shape(left, top, width, height, shapes)

Groups the shapes passed as a parameter into a new GroupShape node of the specified size which is inserted into the specified position.

def insert_group_shape(self, left: float, top: float, width: float, height: float, shapes: List[aspose.words.drawing.Shape]):
    ...
ParameterTypeDescription
leftfloatDistance in points from the origin to the left side of the group shape.
topfloatDistance in points from the origin to the top side of the group shape.
widthfloatThe width of the group shape in points. A negative value is not allowed.
heightfloatThe height of the group shape in points. A negative value is not allowed.
shapesList[Shape]The list of shapes to be grouped.

Remarks

VML and DML shapes cannot be grouped together.

Examples

Shows how to insert DML group shape.

doc = aw.Document()
builder = aw.DocumentBuilder(doc=doc)
shape1 = builder.insert_shape(shape_type=aw.drawing.ShapeType.RECTANGLE, width=200, height=250)
shape1.left = 20
shape1.top = 20
shape1.stroke.color = aspose.pydrawing.Color.red
shape2 = builder.insert_shape(shape_type=aw.drawing.ShapeType.ELLIPSE, width=150, height=200)
shape2.left = 40
shape2.top = 50
shape2.stroke.color = aspose.pydrawing.Color.green
# Dimensions for the new GroupShape node.
left = 10
top = 10
width = 200
height = 300
# Insert GroupShape node for the specified size which is inserted into the specified position.
group_shape1 = builder.insert_group_shape(left=left, top=top, width=width, height=height, shapes=[shape1, shape2])
# Insert GroupShape node which position and dimension will be calculated automatically.
shape3 = shape1.clone(True).as_shape()
group_shape2 = builder.insert_group_shape(shapes=[shape3])
doc.save(file_name=ARTIFACTS_DIR + 'Shape.InsertGroupShape.docx')

See Also