Search code examples
vbacoreldraw

Avoid overlapping curves in Corel draw


I have a lot of circles (curves) in my Corel draw file and I am looking for a way to automatically delete curves that are overlapped. Is there any script or other way to do this?


Solution

  • The following code removes only the overlapping shapes being on top:

    Sub RemoveOverlappedShapesBis()
     Dim sh As Shape, s As Shape, sR As Shape, shR As ShapeRange, d As Document, shrR As New ShapeRange, i As Long
     
     Set d = ActiveDocument
     Set shR = d.ActiveLayer.Shapes.All
     For Each sh In shR.Shapes
        For Each s In shR.Shapes
           If shR.IndexOf(sh) <> shR.IndexOf(s) Then
                If sh.DisplayCurve.IntersectsWith(s.DisplayCurve) Then
                    If s.ZOrder > sh.ZOrder Then
                        If shrR.Count > 0 Then
                            For Each sR In shrR.Shapes
                                 If shrR.IndexOf(s) = 0 Then
                                    shrR.Add s: Exit For
                                End If
                            Next
                        Else
                            shrR.Add s
                        End If
                    End If
                End If
           End If
        Next
     Next
     shrR.Shapes.All.Delete
    End Sub