Sub CreateShapes()
Dim rect As Shape
Dim ellipse As Shape
Dim polygon As Shape
Set rect = ActiveLayer.CreateRectangle(0, 0, 100, 50)
Set ellipse = ActiveLayer.CreateEllipse2(150, 0, 50, 25)
Set polygon = ActiveLayer.CreatePolygon(0, 3, 3, 0, 5, 1, 1, True)
End Sub
Sub ModifyShapeProperties()
Dim sh As Shape
Set sh = ActiveSelectionRange(1)
sh.Fill.UniformColor.RGBAssign 255, 0, 0
sh.Outline.SetProperties Color:=CreateRGBColor(0, 0, 255), Width:=2
sh.RotationAngle = 45
End Sub
Sub ListAllShapes()
Dim sh As Shape
For Each sh In ActivePage.Shapes
Debug.Print "Shape Name: " & sh.Name & ", Type: " & sh.Type
Next sh
End Sub
Sub CreateText()
Dim text As Shape
Set text = ActiveLayer.CreateArtisticText(50, 50, "Hello, CorelDRAW!")
End Sub
Sub 绘制范围线()
Dim s As Shape
Dim sr As ShapeRange
Dim x As Double, y As Double, w As Double, h As Double
ActiveDocument.Unit = cdrMillimeter
Set sr = ActiveSelectionRange
sr.GetBoundingBox x, y, w, h
Set s = ActiveLayer.CreateRectangle2(x, y, w, h)
s.Outline.SetProperties 0.2, OutlineStyles(0), CreateRGBColor(0, 255, 0)
ActiveDocument.ReferencePoint = cdrCenter
s.SetSize w + 14#, h + 3#
x = s.CenterX: y = s.BottomY
sw = s.SizeWidth: sh = s.SizeHeight
text = Int(sw) & "x" & Int(sh) & "mm"
Set s = ActiveLayer.CreateArtisticText(0, 0, text)
s.CenterX = x: s.TopY = y - 10
s.Fill.UniformColor.CMYKAssign 0, 100, 100, 0
End Sub
Sub SetName_Marker()
Set sr = ActiveSelectionRange
sr(1).Name = "TargetLine"
sr(2).Name = "MarkerBlock"
sr(3).Name = "CenterLine"
End Sub
Sub Test()
Const NumLines As Long = 20
Dim s As Shape
Dim pwc As PowerClip
Dim x As Double, y As Double, sx As Double, sy As Double
Dim xx As Double
Dim n As Long
For Each s In ActivePage.Shapes
Set pwc = Nothing
On Error Resume Next
Set pwc = s.PowerClip
On Error GoTo 0
If Not pwc Is Nothing Then
s.CreateSelection
s.GetBoundingBox x, y, sx, sy
pwc.EnterEditMode
For n = 1 To NumLines
xx = x + n * sx / (NumLines + 1)
ActiveLayer.CreateLineSegment xx, y, xx, y + sy
Next n
pwc.LeaveEditMode
End If
Next s
End Sub
Sub TestAbsoluteIndex()
Dim s As Shape
Dim sp As SubPath
Dim seg As Segment
Set s = ActiveShape
If s.Type = cdrCurveShape Then
For Each sp In s.Curve.SubPaths
For Each seg In sp.Segments
Debug.Print seg.Index, seg.AbsoluteIndex
Next seg
Next sp
End If
End Sub