<?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 Differentiate Save from Save As... in AppEvents_OnSaveDocument? in Inventor Programming - iLogic, Macros, AddIns &amp; Apprentice</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/differentiate-save-from-save-as-in-appevents-onsavedocument/m-p/11925898#M151947</link>
    <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;I'm having a macro which updates our database when a file is saved. This uses the AppEvents_OnSaveDocument event (amongst others but this is the problematic one).&lt;/P&gt;&lt;P&gt;The (rare, but annoying) problem is, when someone imports like a STEP file or something, and instead of saving it, he saves it with "save as" under a different name.&lt;/P&gt;&lt;P&gt;However, the event triggered kAfter still thinks the document in question is the imported and unsaved one, it even provides (non-existent, since never saved) filenames and such things - and this is where the macro fails since the file doesn't even exists.&lt;/P&gt;&lt;P&gt;What would be the best and fastest way to circumvent this? Right now I'm checking if the filesavecounter is not 0 before calling the update routine.&lt;/P&gt;&lt;P&gt;I see in the event Context that there are two filenames: one is the imported (unsaved) one and the other is the "save as" name. Could this be reliably used to detect save as?&lt;/P&gt;&lt;P&gt;I just don't wanna check for FileExists every time, that is too slow.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for any ideas.&lt;/P&gt;</description>
    <pubDate>Thu, 27 Apr 2023 13:47:07 GMT</pubDate>
    <dc:creator>bshbsh</dc:creator>
    <dc:date>2023-04-27T13:47:07Z</dc:date>
    <item>
      <title>Differentiate Save from Save As... in AppEvents_OnSaveDocument?</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/differentiate-save-from-save-as-in-appevents-onsavedocument/m-p/11925898#M151947</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;I'm having a macro which updates our database when a file is saved. This uses the AppEvents_OnSaveDocument event (amongst others but this is the problematic one).&lt;/P&gt;&lt;P&gt;The (rare, but annoying) problem is, when someone imports like a STEP file or something, and instead of saving it, he saves it with "save as" under a different name.&lt;/P&gt;&lt;P&gt;However, the event triggered kAfter still thinks the document in question is the imported and unsaved one, it even provides (non-existent, since never saved) filenames and such things - and this is where the macro fails since the file doesn't even exists.&lt;/P&gt;&lt;P&gt;What would be the best and fastest way to circumvent this? Right now I'm checking if the filesavecounter is not 0 before calling the update routine.&lt;/P&gt;&lt;P&gt;I see in the event Context that there are two filenames: one is the imported (unsaved) one and the other is the "save as" name. Could this be reliably used to detect save as?&lt;/P&gt;&lt;P&gt;I just don't wanna check for FileExists every time, that is too slow.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for any ideas.&lt;/P&gt;</description>
      <pubDate>Thu, 27 Apr 2023 13:47:07 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/differentiate-save-from-save-as-in-appevents-onsavedocument/m-p/11925898#M151947</guid>
      <dc:creator>bshbsh</dc:creator>
      <dc:date>2023-04-27T13:47:07Z</dc:date>
    </item>
    <item>
      <title>Re: Differentiate Save from Save As... in AppEvents_OnSaveDocument?</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/differentiate-save-from-save-as-in-appevents-onsavedocument/m-p/11926679#M151966</link>
      <description>&lt;P&gt;Context will work fine.&amp;nbsp; It will either have value named "SaveFileName" or "SaveCopyAsFileName" based on how it's saved.&amp;nbsp; Assemblies are a little more complicated since there will be a slew of kBefore/kAfter triggers in between the kBefore and kAfter for the assembly itself.&amp;nbsp; Just ignore them until you get a kAfter where the "TopLevelSaveFileName" value matches Document.FullFileName, and then grab the "SaveFileName" or "SaveCopyAsFileName" value, whichever exists.&lt;/P&gt;</description>
      <pubDate>Thu, 27 Apr 2023 18:46:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/differentiate-save-from-save-as-in-appevents-onsavedocument/m-p/11926679#M151966</guid>
      <dc:creator>jjstr8</dc:creator>
      <dc:date>2023-04-27T18:46:59Z</dc:date>
    </item>
    <item>
      <title>Re: Differentiate Save from Save As... in AppEvents_OnSaveDocument?</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/differentiate-save-from-save-as-in-appevents-onsavedocument/m-p/11927519#M151980</link>
      <description>&lt;P&gt;I've never worked with context/namevaluemaps, gotta look into it. just simply adding a watch shows the usual "item1", "item2", etc, no name assigned to the values. seems to be hard to figure out which is the save as name, unless they are in a strict order.&lt;/P&gt;&lt;P&gt;Seems to be a lot of extra work, comparisons, etc. (=slow) For now, Savecounter=0 seems to work.&lt;/P&gt;&lt;P&gt;Will experiment with it though, thanks.&lt;/P&gt;</description>
      <pubDate>Fri, 28 Apr 2023 05:21:39 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/differentiate-save-from-save-as-in-appevents-onsavedocument/m-p/11927519#M151980</guid>
      <dc:creator>bshbsh</dc:creator>
      <dc:date>2023-04-28T05:21:39Z</dc:date>
    </item>
    <item>
      <title>Re: Differentiate Save from Save As... in AppEvents_OnSaveDocument?</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/differentiate-save-from-save-as-in-appevents-onsavedocument/m-p/11928783#M152015</link>
      <description>&lt;P&gt;Check the API help for more information.&amp;nbsp; "Context" is just the name of the parameter in the ApplicationEvents.OnSaveDocument event declaration.&amp;nbsp; It's a NameValueMap type, which is essentially a collection of key-value pairs.&amp;nbsp; The help file has information on accessing a NameValueMap object.&amp;nbsp; Accessing "Context" shouldn't be slow, but if you run into anything that seem slow, post your code for others to look at.&amp;nbsp; Inventor doesn't have any checks when accessing a NameValueMap, so if the name doesn't exist it will throw an exception.&amp;nbsp; It's probably easier just to loop through based on Count and look for a specific name.&amp;nbsp; It's 1-based index not a zero-based index in case you've tried it and get an error.&lt;/P&gt;</description>
      <pubDate>Fri, 28 Apr 2023 15:45:34 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/differentiate-save-from-save-as-in-appevents-onsavedocument/m-p/11928783#M152015</guid>
      <dc:creator>jjstr8</dc:creator>
      <dc:date>2023-04-28T15:45:34Z</dc:date>
    </item>
  </channel>
</rss>

