<?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 GUI lifecycle of commands - edit components NOT through the execution event in Fusion API and Scripts Forum</title>
    <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/gui-lifecycle-of-commands-edit-components-not-through-the/m-p/7289037#M17728</link>
    <description>&lt;P&gt;Many Add-in application require an interactive user experience, but model modifications can only be made on execution.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a way to keep the command GUI "alive" during operations? for example changing a component name by calling functionality on an input change event..&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;to the best of my understanding, currently you can &amp;nbsp;only preview changes while the GUI is still alive.&lt;/P&gt;</description>
    <pubDate>Wed, 09 Aug 2017 22:17:37 GMT</pubDate>
    <dc:creator>moshebar</dc:creator>
    <dc:date>2017-08-09T22:17:37Z</dc:date>
    <item>
      <title>GUI lifecycle of commands - edit components NOT through the execution event</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/gui-lifecycle-of-commands-edit-components-not-through-the/m-p/7289037#M17728</link>
      <description>&lt;P&gt;Many Add-in application require an interactive user experience, but model modifications can only be made on execution.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a way to keep the command GUI "alive" during operations? for example changing a component name by calling functionality on an input change event..&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;to the best of my understanding, currently you can &amp;nbsp;only preview changes while the GUI is still alive.&lt;/P&gt;</description>
      <pubDate>Wed, 09 Aug 2017 22:17:37 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/gui-lifecycle-of-commands-edit-components-not-through-the/m-p/7289037#M17728</guid>
      <dc:creator>moshebar</dc:creator>
      <dc:date>2017-08-09T22:17:37Z</dc:date>
    </item>
    <item>
      <title>Re: GUI lifecycle of commands - edit components NOT through the execution event</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/gui-lifecycle-of-commands-edit-components-not-through-the/m-p/7289081#M17729</link>
      <description>&lt;P&gt;Model modifications can be made both on the execution of a command and also in the executePreview of a command. &amp;nbsp;The issue is that the changes made in the executePreview will be aborted if you cancel the command or when the execute if finally done, unless you've set the isValidResult property of the ComandEventArgs that's passed into the executePreview to True. &amp;nbsp;If that's the case then when the command is executed the changes made in the executePreview will be used&amp;nbsp;and the execute event won't be fired.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But I think what you're wanting is for a single command to make as series of changes, saving each one as you go. &amp;nbsp;This isn't supported by the current Fusion 360 command architecture. &amp;nbsp;See if you can find any Fusion commands that provides this capability. You might be able to do something that would provide similar functionality by automatically invoking your command again after it's been executed but I haven't tried that to see if it would all work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The way a command works is that when the user clicks the ribbon button, the command is created which results in the commandCreated event being fired where you define the contents of the command dialog and connect to other command related events. Whenever changes are made to the inputs the inputChanged, validateInputs, and executePreview events are fired. You can do whatever you want in the executePreview to illustrate what the final result will be. &amp;nbsp;Often times this is doing the actual work to create the final result. &amp;nbsp;Whatever you do it is encapsulated within a "transaction". &amp;nbsp;With the next change to any of the inputs that transaction is aborted so all those changes are lost and you're back to the state where the command started. &amp;nbsp;When the OK&amp;nbsp;button is clicked, the execute event is fired and you can created the final result. &amp;nbsp;This work done in the execute event is&amp;nbsp;also encapsulated within a single transaction, which is why there is a single item in the undo list. &amp;nbsp;It's just that this final transaction remains and isn't aborted.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Another option to maybe get the desired effect you're looking for is to use the palette functionality. &amp;nbsp;A palette&amp;nbsp;isn't associated with a command and can remain visible anytime. &amp;nbsp;The content of a palette is defined using&amp;nbsp;html so it's entirely different than a command dialog and the various command inputs used to define the content of the dialog.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It could also be that in the future Fusion 360 will support the ability to apply and save the current changes while the command continues to run. &amp;nbsp;If that should happen&amp;nbsp;I expect that we'll also expose that through the API but for now it's not available.&lt;/P&gt;</description>
      <pubDate>Wed, 09 Aug 2017 22:52:54 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/gui-lifecycle-of-commands-edit-components-not-through-the/m-p/7289081#M17729</guid>
      <dc:creator>ekinsb</dc:creator>
      <dc:date>2017-08-09T22:52:54Z</dc:date>
    </item>
    <item>
      <title>Re: GUI lifecycle of commands - edit components NOT through the execution event</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/gui-lifecycle-of-commands-edit-components-not-through-the/m-p/7289931#M17730</link>
      <description>&lt;P&gt;Thanks for the detailed reply.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think I have solved this and would like to share here for other developers:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;step 1:&lt;/P&gt;&lt;P&gt;somewhere in the CommandCreatedEventHandler:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;command-&amp;gt;isAutoExecute(false); //do not auto execute on close&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;command-&amp;gt;isExecutedWhenPreEmpted(false);//do not auto execute when other commands are executed&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;step 2:&lt;/P&gt;&lt;P&gt;make a global flag to designate running of specific function during execution&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;bool runFunX = false;// default false&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;step 3:&lt;/P&gt;&lt;P&gt;tag the flag on a specific input trigger in&amp;nbsp;InputChangedEventHandler and call execution within that event&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;lastInput = eventArgs-&amp;gt;input();&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;string input_id =&amp;nbsp;&lt;SPAN&gt;lastInput&amp;nbsp;-&amp;gt;id();&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; if (input_id&amp;nbsp; == "my_command_input_id")&lt;BR /&gt;&amp;nbsp; &amp;nbsp; {&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; runFunX&amp;nbsp;= true;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; command-&amp;gt;doExecute(false); //false - execute without terminating&amp;nbsp;GUI&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; runFunX&amp;nbsp;= false;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; }&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;step 4:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;within the execute event CommandEventHandler call the function if the flag is up:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp;if (runFunX)&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; FunX();&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;hope someone might find this useful.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Moshe&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 10 Aug 2017 09:10:20 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/gui-lifecycle-of-commands-edit-components-not-through-the/m-p/7289931#M17730</guid>
      <dc:creator>moshebar</dc:creator>
      <dc:date>2017-08-10T09:10:20Z</dc:date>
    </item>
  </channel>
</rss>

