Message 1 of 3
Remove duplicate objects from collection and compare to another collection
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Right now I am writing some code that automatically finds all the start and end points of line segments to be placed in an ordinate set.
I currently have code that creates a set on the left and right side, however, because 2 separate collections are required they sometimes have values that overlap. For example, both sides have a 1 1/2 measurement. I would like to only have one on the left side.
I have been trying to write a function to compare the 2 lists and remove any value that is the same in the second list, but I have had no success getting it to work. Part of the kicker is that the first entry in both lists will be the same and has to avoid deletion.
Any help would be appreciated.
Public Function CheckForDuplicates (Col1 As ObjectCollection, Col2 As ObjectCollection) As ObjectCollection Dim FirstPoint As GeometryIntent Dim SecondPoint As GeometryIntent Dim oNewCol As ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection For item =1 To Col2.Count oNewCol.Add(Col2.Item(item)) Next For i=2 To Col1.Count FirstPoint = Col1.Item(i) For j=1 To Col2.Count SecondPoint = Col2.Item(j) If FirstPoint.PointOnSheet.X = SecondPoint.PointOnSheet.X Or FirstPoint.PointOnSheet.Y = SecondPoint.PointOnSheet.Y oNewCol.Remove(j) End If Next Next Return oNewCol End Function