Previous Document Next Document

Object Model Reference : Classes : S : ShapeRange : Methods : ShapeRange.Group


ShapeRange.Group

Function Group() As Shape

Description

Member of ShapeRange

The Group method groups all the shapes in a shape range and returns a Shape object as the reference to the group.

VBA example

The following VBA example creates a jigsaw puzzle.

Sub Test()
 Dim s As Shape, sp As SubPath, sbmp As Shape
 Dim sr As New ShapeRange, n As Long
 Dim x As Double, y As Double, sx As Double, sy As Double
 Set s = ActiveLayer.CreateCurve
 Set sp = s.Curve.CreateSubPath(1.351, 8.545)
 sp.AppendCurveSegment False, 1.351, 8.926, 0.127, 89.901, 0.127, -64.56
 sp.AppendCurveSegment False, 1.156, 8.952, 0.066, 115.44, 0.066, -48.906
 sp.AppendCurveSegment False, 1.156, 9.15, 0.065, 131.09, 0.065, -133.149
 sp.AppendCurveSegment False, 1.351, 9.163, 0.065, 46.846, 0.065, -116.315
 sp.AppendCurveSegment False, 1.351, 9.545, 0.127, 63.683, 0.127, -89.902
 sp.AppendCurveSegment False, 0.976, 9.545, 0.125, 179.951, 0.125, 25.612
 sp.AppendCurveSegment False, 0.96, 9.342, 0.063, -154.391, 0.063, 40.943
 sp.AppendCurveSegment False, 0.767, 9.339, 0.067, -139.06, 0.067, -41.987
 sp.AppendCurveSegment False, 0.752, 9.547, 0.063, 138.014, 0.065, -33.906
 sp.AppendCurveSegment False, 0.351, 9.545, 0.134, 146.087, 0.134, 0.045
 sp.AppendCurveSegment False, 0.351, 9.163, 0.127, -90#, 0.127, 63.681
 sp.AppendCurveSegment False, 0.156, 9.15, 0.065, -116.317, 0.065, 46.846
 sp.AppendCurveSegment False, 0.156, 8.952, 0.065, -133.152, 0.065, 131.093
 sp.AppendCurveSegment False, 0.351, 8.926, 0.066, -48.906, 0.066, 115.439
 sp.AppendCurveSegment False, 0.351, 8.545, 0.127, -64.561, 0.127, 90#
 sp.AppendCurveSegment False, 0.752, 8.547, 0.134, 0.002, 0.134, 146.087
 sp.AppendCurveSegment False, 0.767, 8.339, 0.065, -33.908, 0.063, 138.012
 sp.AppendCurveSegment False, 0.96, 8.342, 0.067, -41.987, 0.067, -139.058
 sp.AppendCurveSegment False, 0.976, 8.545, 0.063, 40.943, 0.063, -154.388
 sp.AppendCurveSegment False, 1.351, 8.545, 0.125, 25.613, 0.125, 179.998
 sp.Closed = True
 For n = 1 To 7
  sr.Add s.Duplicate
  s.Move 1, 0
 Next n
 sr.Add s
 sr.AddRange sr.Duplicate(0, -1)
 sr.AddRange sr.Duplicate(0, -2)
 Set s = sr.Group
 s.GetBoundingBox x, y, sx, sy
 Set sbmp = ActiveLayer.CreateRectangle2(x, y, sx, sy)
 sbmp.Fill.ApplyTextureFill "Gouache wash", "Samples"
 Set sbmp = sbmp.ConvertToBitmapEx(cdrRGBColorImage, , , 120)
 sbmp.AddToPowerClip s
 s.Ungroup
 For Each s In sr
  s.Move (Rnd() - 0.5) * 0.25, (Rnd() - 0.5) * 0.25
 Next s
End Sub

Previous Document Next Document Back to Top

Copyright 2013 Corel Corporation. All rights reserved.