<?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: Missing dataFileComplete events after using saveCopyAs in Fusion API and Scripts Forum</title>
    <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/missing-datafilecomplete-events-after-using-savecopyas/m-p/11808980#M4254</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/3787950"&gt;@kandennti&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;That is the behavior I sometimes see as well. It calls the event handler with the same file argument multiple times at times which is very unfortunate.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Are there any other ways to check if a file has been saved?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
    <pubDate>Thu, 09 Mar 2023 05:20:17 GMT</pubDate>
    <dc:creator>sent-hil</dc:creator>
    <dc:date>2023-03-09T05:20:17Z</dc:date>
    <item>
      <title>Missing dataFileComplete events after using saveCopyAs</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/missing-datafilecomplete-events-after-using-savecopyas/m-p/11808372#M4252</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to write a script that copies over a base file x number of times and then sets different custom parameters in those files based on the file name. The script is here:&amp;nbsp;&lt;A href="https://gist.github.com/sent-hil/aa0c1f30abbf5b852de3cb348934c998" target="_blank"&gt;https://gist.github.com/sent-hil/aa0c1f30abbf5b852de3cb348934c998&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm using this following code to listen to file creation:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;onDataFileComplete = MyDataFileCompleteHandler()&lt;BR /&gt;app.dataFileComplete.add(onDataFileComplete)&lt;BR /&gt;handlers.append(onDataFileComplete)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the script&amp;nbsp;MyDataFileCompleteHandler#notify does nothing but logs `args.file.name`. When I run the script I expect to see `MyDataFileCompleteHandler: &amp;lt;file name` 6 times, however, at times I'll see it 4 times or sometimes 5 times. As x increases, the chances of events being dropped increase. No matter how long I wait, the remaining&amp;nbsp;onDataFileComplete are never fired.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried using `time.sleep` and&amp;nbsp;&amp;nbsp;`adsk.doEvents()` to let it complete, but that didn't help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Bug in API perhaps? Would appreciate some help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Senthil&lt;/P&gt;&lt;P&gt;&lt;A href="https://toolwallhq.com" target="_blank" rel="noopener"&gt;ToolWall&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Mar 2023 21:55:10 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/missing-datafilecomplete-events-after-using-savecopyas/m-p/11808372#M4252</guid>
      <dc:creator>sent-hil</dc:creator>
      <dc:date>2023-03-08T21:55:10Z</dc:date>
    </item>
    <item>
      <title>Re: Missing dataFileComplete events after using saveCopyAs</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/missing-datafilecomplete-events-after-using-savecopyas/m-p/11808973#M4253</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/10793169"&gt;@sent-hil&lt;/a&gt;&amp;nbsp;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Perhaps the variable "handlers" is released before the process is complete, and therefore the event is not fired.&lt;BR /&gt;Simply put, I don't think the dataFileComplete event is available to the script.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have created an add-in to try the same process and have attached it for your reference.&lt;BR /&gt;After launching the add-in, you can execute this command to display the dialog.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="1.png" style="width: 348px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1186433iCB2B3B440480B636/image-size/large?v=v2&amp;amp;px=999" role="button" title="1.png" alt="1.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The execution result is here.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="1.png" style="width: 864px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1186434i98E81F9B99BC94BD/image-size/large?v=v2&amp;amp;px=999" role="button" title="1.png" alt="1.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, when trying several times, it sometimes outputs incorrect messages as shown below, but we could not find the cause.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="1.png" style="width: 298px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1186435iB8B9798DE2FB4ECF/image-size/large?v=v2&amp;amp;px=999" role="button" title="1.png" alt="1.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Mar 2023 05:15:05 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/missing-datafilecomplete-events-after-using-savecopyas/m-p/11808973#M4253</guid>
      <dc:creator>kandennti</dc:creator>
      <dc:date>2023-03-09T05:15:05Z</dc:date>
    </item>
    <item>
      <title>Re: Missing dataFileComplete events after using saveCopyAs</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/missing-datafilecomplete-events-after-using-savecopyas/m-p/11808980#M4254</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/3787950"&gt;@kandennti&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;That is the behavior I sometimes see as well. It calls the event handler with the same file argument multiple times at times which is very unfortunate.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Are there any other ways to check if a file has been saved?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Thu, 09 Mar 2023 05:20:17 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/missing-datafilecomplete-events-after-using-savecopyas/m-p/11808980#M4254</guid>
      <dc:creator>sent-hil</dc:creator>
      <dc:date>2023-03-09T05:20:17Z</dc:date>
    </item>
    <item>
      <title>Re: Missing dataFileComplete events after using saveCopyAs</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/missing-datafilecomplete-events-after-using-savecopyas/m-p/11809016#M4255</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/10793169"&gt;@sent-hil&lt;/a&gt;&amp;nbsp;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How about checking with the datafiles.asArray method?&lt;/P&gt;
&lt;P&gt;&lt;A href="https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-1BB4CB50-4CBA-4FD6-9250-C2CC501B9058" target="_blank" rel="noopener"&gt;https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-1BB4CB50-4CBA-4FD6-9250-C2CC501B9058&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Mar 2023 05:44:43 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/missing-datafilecomplete-events-after-using-savecopyas/m-p/11809016#M4255</guid>
      <dc:creator>kandennti</dc:creator>
      <dc:date>2023-03-09T05:44:43Z</dc:date>
    </item>
    <item>
      <title>Re: Missing dataFileComplete events after using saveCopyAs</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/missing-datafilecomplete-events-after-using-savecopyas/m-p/11821703#M4256</link>
      <description>&lt;P&gt;Unfortunately, that didn't work either. I kept getting 'can't download file' when trying to open the file from the array, even though the file existed in the array.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;However, I was able to solve the problem by modifying the user parameters first, then using `Document#saveAs` to save to a new document.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;for file_name, user_params in HOLDERS.items():
    # Open the current document
    opened_document = app.documents.open(current_data_file, True)
    opened_design = app.activeProduct

    # Set user parameters
    for param_name, param_value in user_params.items():
        param = opened_design.userParameters.itemByName(param_name)
        if param:
            param.expression = param_value
    
    # Save the modified document in the new folder
    opened_document.saveAs(file_name, new_folder, '', '')
    opened_document.close(False)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your reply.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Mar 2023 23:06:16 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/missing-datafilecomplete-events-after-using-savecopyas/m-p/11821703#M4256</guid>
      <dc:creator>sent-hil</dc:creator>
      <dc:date>2023-03-14T23:06:16Z</dc:date>
    </item>
  </channel>
</rss>

