【CorelDraw VBA 007例】旋转到参考点对象

Sub RotEach()
    '##旋转到参考点对象
    Dim s As Shape
    Dim x As Double
    Dim y As Double
    Dim ro As Double
    ActiveDocument.Unit = cdrMillimeter
    ActiveDocument.DrawingOriginX = 0 ' x and y = 0 - seems to set origin
    ActiveDocument.DrawingOriginY = 0 ' to centre of page
    ActiveDocument.ReferencePoint = cdrCenter
    Optimization = True
    For Each s In ActivePage.Shapes ' could be changed to activeselection
        x = s.PositionX
        y = s.PositionY
        If x < 0 And y <> 0 Then ro = Atn(y / x) * 57.29577 + 90 'Atan in radians - converts to degrees and adds right angle
        If x > 0 And y <> 0 Then ro = Atn(y / x) * 57.29577 - 90
        If x = 0 And y > 0 Then ro = 0
        If x = 0 And y < 0 Then ro = 180
        If y = 0 And x > 0 Then ro = 270
        If y = 0 And x < 0 Then ro = 90
        If y = 0 And x = 0 Then ro = 0
        s.Rotate ro
    Next s
    Optimization = False
    ActiveWindow.Refresh
End Sub

  

posted @ 2021-11-24 09:17  岳帆(SoSo)  阅读(152)  评论(0)    收藏  举报