<?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 Re: Parsing the Recent Changes Enum in Inventor Programming - iLogic, Macros, AddIns &amp; Apprentice</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/parsing-the-recent-changes-enum/m-p/7245477#M73687</link>
    <description>&lt;P&gt;As a temporary solution I just wrote this shoddy function. Which I hate doing; because if there is a native way something can be done, it should be done that way instead of just bringing more redundant code into the world.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Sub Main()
	oRecentChanges = ThisDoc.Document.RecentChanges
	
    Dim oChangeList As New List(Of Integer)
	
	MsgBox(CStr(oRecentChanges))
	
    oChangeList = ParseEnum(oRecentChanges)
    
	Call PrintList(oChangeList)
End Sub

Function ParseEnum(oVal As Integer) As Object
    Dim oEnumList As New List(Of Integer)

    For Each i In [Enum].GetValues(GetType(CommandTypesEnum))
        oEnumList.Add(i)
    Next
    
    oEnumList.Sort
    oEnumList.Reverse

    Dim oOutputList As New List(Of Integer)
 
    For Each oItem in oEnumList
        If oVal - oItem &amp;gt; -1 Then
            oVal = oVal - oItem
            oOutputList.Add(oItem)
        End If
    Next
    Return oOutputList
End Function

Sub PrintList(oList As Object)
    For Each oItem in oList
        oStr = oStr &amp;amp; vbLf &amp;amp; oItem
    Next
    MsgBox(oStr)
End Sub&lt;/PRE&gt;</description>
    <pubDate>Fri, 21 Jul 2017 16:09:09 GMT</pubDate>
    <dc:creator>MechMachineMan</dc:creator>
    <dc:date>2017-07-21T16:09:09Z</dc:date>
    <item>
      <title>Parsing the Recent Changes Enum</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/parsing-the-recent-changes-enum/m-p/7245332#M73685</link>
      <description>&lt;P&gt;I've tried a couple different things but I cant seem to get it to click.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What I want to do is use the RecentChanges property of a document to control when I want a global event trigger to proceed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I understand that the RecentChanges returns an enum that is an addition of the children that are flagged, but what I can't currently do is establish out of that value which of the children are flagged on without writing a large tree structure.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;From the browsing I have done on the msdn site, it looks like enums are set-up to get them to do this for you, in the form of an array, but I can't seem to get it working.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ie; if oDoc.RecentChanges returns a value of 145, I want to find the function/method that spits an array out containing only (128, 16, 1) so then I can do an "If array contains 128 OR ARRAY Contains 32"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is the mishmash of things I have tried so far:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Dim oDoc As Document = ThisDoc.Document
&lt;BR /&gt;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''&lt;BR /&gt;
''Below fails because it says RecentChanges is not a collection
'For Each i In oDoc.RecentChanges
'	MsgBox(i)
'Next
&lt;BR /&gt;''''''''''''''''''''''''''''''''''''''''''''''''&lt;BR /&gt;&lt;BR /&gt;''Below simply returns the value of the combined enums; in my test case, this was 145 (which is 128, 16, 1)
MsgBox(CStr(oDoc.RecentChanges))&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;''''''''''''''''''''''''''''''''''''''''''''''''&lt;BR /&gt;'Below says that commandtypesenums is not part of ienumerable
&lt;SPAN&gt;For&lt;/SPAN&gt; &lt;SPAN&gt;Each&lt;/SPAN&gt; &lt;SPAN&gt;i&lt;/SPAN&gt; &lt;SPAN&gt;In&lt;/SPAN&gt;&lt;SPAN&gt; [&lt;/SPAN&gt;&lt;SPAN&gt;Enum&lt;/SPAN&gt;&lt;SPAN&gt;].&lt;/SPAN&gt;&lt;SPAN&gt;Parse&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;GetType&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;CommandTypesEnum&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;oDoc&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;RecentChanges&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt; &lt;BR /&gt;&lt;SPAN&gt;    MsgBox&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;i&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;Next&lt;BR /&gt;&lt;/SPAN&gt;
''''''''''''''''''''''''''''''''''''''''''''''''&lt;BR /&gt;'Below just lists all possible enums in CommandTypesEnum
For Each i In  [Enum].GetValues(GetType(CommandTypesEnum))
    MsgBox(i)
Next
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Jul 2017 15:30:42 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/parsing-the-recent-changes-enum/m-p/7245332#M73685</guid>
      <dc:creator>MechMachineMan</dc:creator>
      <dc:date>2017-07-21T15:30:42Z</dc:date>
    </item>
    <item>
      <title>Re: Parsing the Recent Changes Enum</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/parsing-the-recent-changes-enum/m-p/7245477#M73687</link>
      <description>&lt;P&gt;As a temporary solution I just wrote this shoddy function. Which I hate doing; because if there is a native way something can be done, it should be done that way instead of just bringing more redundant code into the world.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Sub Main()
	oRecentChanges = ThisDoc.Document.RecentChanges
	
    Dim oChangeList As New List(Of Integer)
	
	MsgBox(CStr(oRecentChanges))
	
    oChangeList = ParseEnum(oRecentChanges)
    
	Call PrintList(oChangeList)
End Sub

Function ParseEnum(oVal As Integer) As Object
    Dim oEnumList As New List(Of Integer)

    For Each i In [Enum].GetValues(GetType(CommandTypesEnum))
        oEnumList.Add(i)
    Next
    
    oEnumList.Sort
    oEnumList.Reverse

    Dim oOutputList As New List(Of Integer)
 
    For Each oItem in oEnumList
        If oVal - oItem &amp;gt; -1 Then
            oVal = oVal - oItem
            oOutputList.Add(oItem)
        End If
    Next
    Return oOutputList
End Function

Sub PrintList(oList As Object)
    For Each oItem in oList
        oStr = oStr &amp;amp; vbLf &amp;amp; oItem
    Next
    MsgBox(oStr)
End Sub&lt;/PRE&gt;</description>
      <pubDate>Fri, 21 Jul 2017 16:09:09 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/parsing-the-recent-changes-enum/m-p/7245477#M73687</guid>
      <dc:creator>MechMachineMan</dc:creator>
      <dc:date>2017-07-21T16:09:09Z</dc:date>
    </item>
  </channel>
</rss>

