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.
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
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?
Deleting a visible element in VBA
This code should be work
Answer Verified By: caddcop
That did the trick. I also realized my code had an error but its fixed now. Had <> instead of = in my if test for zero length. I had started to look at multiple tests and started with not zero and never changed it when I decided to keep it simple'
Charles (Chuck) Rheault CADD Manager
MDOT State Highway Administration