Collection1 - Collectoin2 = Collection3?

Collection1 - Collectoin2 = Collection3?

mdhutchinson
Advisor Advisor
410 Views
3 Replies
Message 1 of 4

Collection1 - Collectoin2 = Collection3?

mdhutchinson
Advisor
Advisor
Can anyone point me to a function, or give me some idea how I might write a function that will do the following?

Collection#1 minus Collection#2 returns Collection#3
0 Likes
411 Views
3 Replies
Replies (3)
Message 2 of 4

Anonymous
Not applicable
The first thing that comes to my mind is

pseudocode:

for each object in Collection_2

if (object is in Collectioon_1) then

' Nothing

else

' Put the index in Collection_1 of that object into
' a collection of index called Collection_Index

end if

next

for each index in Collection_Index

Collection_1.Remove index

next

end of pseudocode

Note: you can't remove items from a collection you iterate in. Oh,
Collection_1 and Collection_2 should contain the same kind of objects.

Gilles Plante

wrote in message news:[email protected]...
Can anyone point me to a function, or give me some idea how I might write a
function that will do the following?

Collection#1 minus Collection#2 returns Collection#3
0 Likes
Message 3 of 4

Anonymous
Not applicable
I did this:

Public Function FilterSelectionSets(ssLocal As AcadSelectionSet, ssLocalTol As AcadSelectionSet)
Dim oPoly As AcadPolyline
Dim oPoly2 As AcadPolyline
Dim iCount As Integer
Dim aryItems() As AcadEntity

If ssLocal.Count > 0 Then
iCount = 0
For Each oPoly In ssLocal
For Each oPoly2 In ssLocalTol
If oPoly2.Handle = oPoly.Handle Then
' This is the same entity - we want to remove
' Increase array size
ReDim Preserve aryItems(0 To iCount)
' Add to array
Set aryItems(iCount) = oPoly2
' Update for next match
iCount = iCount + 1
Exit For
End If
Next
Next

ssLocalTol.RemoveItems aryItems
Erase aryItems
End If
End Function
0 Likes
Message 4 of 4

Anonymous
Not applicable
On Thu, 01 Feb 2007 21:04:47 +0530, Gilles Plante wrote:

Hello,

It is possible to remove items from the collection that you are iterating
if you do it in the reverse direction


FOR i = Collection.count - 1 to 0 STEP -1


rem - it possible to do anything in this loop that removes an item from
the collection


next i


rgds

Dilip Damle
>
> Note: you can't remove items from a collection you iterate in. Oh,
> Collection_1 and Collection_2 should contain the same kind of objects.
>
--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
0 Likes