[CONNECT VBA] Deleting Zero Length Elements

I have a library with hundreds of cells. All of the cells have one or more zero length elements at their origins. In V8i, to create a graphic cell that only the origin was snappable, these were needed. In CONNECT, they are no longer needed an as part of a complete cleanup of our cell libraries, I want to remove them. In some cells, there are zero length linestrings while others are lines, and I have found a few with some of each.

I am very rusty with my VBA skills. I looked at element enumerators to select elements and I can skip over elements that fail my length test. But I cannot figure out how to delete the element once it is found.

My current code needs a selection set to start, but I am not sure that is the correct approach. Note - this code is only looking at lines. I believe adding line strings to the mix is trivial. At least, it seems easier than deleting the elements once they pass my tests.

Sub DeleteZeroWtLine()
    Dim oEnumerator As ElementEnumerator

    Set oEnumerator = ActiveModelReference.GetSelectedElements

    Do While oEnumerator.MoveNext
        Dim oElement As Element

        Set oElement = oEnumerator.Current

        If oElement.Type = msdElementTypeLine Then
            If oElement.AsLineElement.Length = 0 Then
'               Need code to delete any elements that get to this point
            End If
        End If
    Loop

    ActiveModelReference.UnselectAllElements
End Sub

Looking at the scan criteria approach will probably speed up the process, but I believe it will leave me with the same question - how to delete the current element in an enumerator?

Parents Reply Children
No Data