<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Collection1 - Collectoin2 = Collection3? in VBA Forum</title>
    <link>https://forums.autodesk.com/t5/vba-forum/collection1-collectoin2-collection3/m-p/1878616#M27808</link>
    <description>Can anyone point me to a function, or give me some idea how I might write a function that will do the following?&lt;BR /&gt;
&lt;BR /&gt;
Collection#1 minus Collection#2 returns Collection#3</description>
    <pubDate>Thu, 01 Feb 2007 14:18:04 GMT</pubDate>
    <dc:creator>mdhutchinson</dc:creator>
    <dc:date>2007-02-01T14:18:04Z</dc:date>
    <item>
      <title>Collection1 - Collectoin2 = Collection3?</title>
      <link>https://forums.autodesk.com/t5/vba-forum/collection1-collectoin2-collection3/m-p/1878616#M27808</link>
      <description>Can anyone point me to a function, or give me some idea how I might write a function that will do the following?&lt;BR /&gt;
&lt;BR /&gt;
Collection#1 minus Collection#2 returns Collection#3</description>
      <pubDate>Thu, 01 Feb 2007 14:18:04 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/collection1-collectoin2-collection3/m-p/1878616#M27808</guid>
      <dc:creator>mdhutchinson</dc:creator>
      <dc:date>2007-02-01T14:18:04Z</dc:date>
    </item>
    <item>
      <title>Re: Collection1 - Collectoin2 = Collection3?</title>
      <link>https://forums.autodesk.com/t5/vba-forum/collection1-collectoin2-collection3/m-p/1878617#M27809</link>
      <description>The first thing that comes to my mind is&lt;BR /&gt;
&lt;BR /&gt;
pseudocode:&lt;BR /&gt;
&lt;BR /&gt;
for each object in Collection_2&lt;BR /&gt;
&lt;BR /&gt;
    if (object is in Collectioon_1) then&lt;BR /&gt;
&lt;BR /&gt;
        '  Nothing&lt;BR /&gt;
&lt;BR /&gt;
    else&lt;BR /&gt;
&lt;BR /&gt;
        ' Put the index in Collection_1 of that object into&lt;BR /&gt;
        ' a collection of index called Collection_Index&lt;BR /&gt;
&lt;BR /&gt;
    end if&lt;BR /&gt;
&lt;BR /&gt;
next&lt;BR /&gt;
&lt;BR /&gt;
for each index in Collection_Index&lt;BR /&gt;
&lt;BR /&gt;
   Collection_1.Remove index&lt;BR /&gt;
&lt;BR /&gt;
next&lt;BR /&gt;
&lt;BR /&gt;
end of pseudocode&lt;BR /&gt;
&lt;BR /&gt;
Note: you can't remove items from a collection you iterate in. Oh,&lt;BR /&gt;
Collection_1 and Collection_2 should contain the same kind of objects.&lt;BR /&gt;
&lt;BR /&gt;
Gilles Plante&lt;BR /&gt;
&lt;BR /&gt;
&lt;HUTCH&gt; wrote in message news:5471339@discussion.autodesk.com...&lt;BR /&gt;
Can anyone point me to a function, or give me some idea how I might write a &lt;BR /&gt;
function that will do the following?&lt;BR /&gt;
&lt;BR /&gt;
Collection#1 minus Collection#2 returns Collection#3&lt;/HUTCH&gt;</description>
      <pubDate>Thu, 01 Feb 2007 15:34:47 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/collection1-collectoin2-collection3/m-p/1878617#M27809</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2007-02-01T15:34:47Z</dc:date>
    </item>
    <item>
      <title>Re: Collection1 - Collectoin2 = Collection3?</title>
      <link>https://forums.autodesk.com/t5/vba-forum/collection1-collectoin2-collection3/m-p/1878618#M27810</link>
      <description>I did this:&lt;BR /&gt;
&lt;BR /&gt;
Public Function FilterSelectionSets(ssLocal As AcadSelectionSet, ssLocalTol As AcadSelectionSet)&lt;BR /&gt;
    Dim oPoly As AcadPolyline&lt;BR /&gt;
    Dim oPoly2 As AcadPolyline&lt;BR /&gt;
    Dim iCount As Integer&lt;BR /&gt;
    Dim aryItems() As AcadEntity&lt;BR /&gt;
    &lt;BR /&gt;
    If ssLocal.Count &amp;gt; 0 Then&lt;BR /&gt;
        iCount = 0&lt;BR /&gt;
        For Each oPoly In ssLocal&lt;BR /&gt;
            For Each oPoly2 In ssLocalTol&lt;BR /&gt;
                If oPoly2.Handle = oPoly.Handle Then&lt;BR /&gt;
                    ' This is the same entity - we want to remove&lt;BR /&gt;
                    ' Increase array size&lt;BR /&gt;
                    ReDim Preserve aryItems(0 To iCount)&lt;BR /&gt;
                    ' Add to array&lt;BR /&gt;
                    Set aryItems(iCount) = oPoly2&lt;BR /&gt;
                    ' Update for next match&lt;BR /&gt;
                    iCount = iCount + 1&lt;BR /&gt;
                    Exit For&lt;BR /&gt;
                End If&lt;BR /&gt;
            Next&lt;BR /&gt;
        Next&lt;BR /&gt;
        &lt;BR /&gt;
        ssLocalTol.RemoveItems aryItems&lt;BR /&gt;
        Erase aryItems&lt;BR /&gt;
    End If&lt;BR /&gt;
End Function</description>
      <pubDate>Thu, 01 Feb 2007 17:20:33 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/collection1-collectoin2-collection3/m-p/1878618#M27810</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2007-02-01T17:20:33Z</dc:date>
    </item>
    <item>
      <title>Re: Collection1 - Collectoin2 = Collection3?</title>
      <link>https://forums.autodesk.com/t5/vba-forum/collection1-collectoin2-collection3/m-p/1878619#M27811</link>
      <description>On Thu, 01 Feb 2007 21:04:47 +0530, Gilles Plante &lt;INFO&gt; wrote:&lt;BR /&gt;
&lt;BR /&gt;
Hello,&lt;BR /&gt;
&lt;BR /&gt;
It is possible to remove items from the collection that you are iterating  &lt;BR /&gt;
if you do it in the reverse direction&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
FOR i = Collection.count - 1 to 0 STEP -1&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
rem - it possible to do anything in this loop that removes an item from  &lt;BR /&gt;
the collection&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
next i&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
rgds&lt;BR /&gt;
&lt;BR /&gt;
Dilip Damle&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt; Note: you can't remove items from a collection you iterate in. Oh,&lt;BR /&gt;
&amp;gt; Collection_1 and Collection_2 should contain the same kind of objects.&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
-- &lt;BR /&gt;
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/&lt;/INFO&gt;</description>
      <pubDate>Sat, 03 Feb 2007 04:10:50 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/collection1-collectoin2-collection3/m-p/1878619#M27811</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2007-02-03T04:10:50Z</dc:date>
    </item>
  </channel>
</rss>

