use RemoveOverlaps on collection of shapes

There is a function in the api called RemoveOverlaps, which seeks for overlaps in one curve. Is there a way to use this function over multiple curves from multiple shapes?

In short i try to remove double lines in my drawing soo my lasercutter does not cut that line twice.

Thanks

Parents
No Data
Reply
  • My approach - sort of brute force ;) Slow on complex and large number of objects.

    Sub Cut()
    If ActiveSelectionRange.Count = 0 Then   
        Exit Sub
    End If
    Dim s, sCopy As Shape, l, temp As Layer, sr As ShapeRange, srCount As Integer, coll As New Collection
    ActiveDocument.Unit = cdrMillimeter
    ActiveDocument.BeginCommandGroup "Get curves cut ready"
    Optimization = True
    EventsEnabled = False
    ActiveDocument.PreserveSelection = False
    Set l = ActiveDocument.ActiveLayer
    Set sr = ActiveSelectionRange
    Set temp = ActivePage.CreateLayer("Temp")
    sr.MoveToLayer temp
    For i = 1 To sr.Shapes.Count   
        Set s = sr(i)
        If s.Type <> cdrCurveShape Then s.ConvertToCurves   
        s.Curve.Nodes.All.BreakApart
        s.BreakApart   
        Dim tempSr As ShapeRange
        Set tempSr = ActiveSelectionRange
        coll.Add tempSr       
    Next i
    For i = 1 To coll.Count
        Set sr = coll(i)   
        For j = 1 To sr.Count   
            Set s = sr(j)
            Set sCopy = s.Duplicate(0, 0)
            sCopy.Outline.width = 1
            sCopy.Outline.ConvertToObject       
            For k = 1 To coll.Count       
                If k <> i Then           
                    Dim sr1 As ShapeRange
                    Set sr1 = coll(k)               
                    srCount = sr1.Count               
                        For h = 1 To srCount                   
                            Set s = sr1(h)
                            Set s = sCopy.Trim(s, True, True)
                            If Not s Is Nothing Then
                                sr1.Add s
                            End If                       
                        Next h                   
                        For m = srCount To 1 Step -1                       
                            sr1(m).Delete
                            sr1.Remove m                   
                        Next m
                End If
            Next k
        sCopy.Delete   
        Next j
    Next i
    ActiveDocument.ActiveLayer.Shapes.All.MoveToLayer l
    temp.Delete
    ActiveDocument.ClearSelection
    Optimization = False
    ActiveDocument.PreserveSelection = True
    EventsEnabled = True
    Application.Refresh
    ActiveDocument.EndCommandGroup
    End Sub

Children
No Data