<?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: Background Process API Access? in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/background-process-api-access/m-p/11938784#M12262</link>
    <description>&lt;P&gt;As always, thank you!&amp;nbsp; It looks like it's time to start digging into APS.&lt;/P&gt;</description>
    <pubDate>Wed, 03 May 2023 13:30:27 GMT</pubDate>
    <dc:creator>Kevin.Lawson.PE</dc:creator>
    <dc:date>2023-05-03T13:30:27Z</dc:date>
    <item>
      <title>Background Process API Access?</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/background-process-api-access/m-p/11937077#M12260</link>
      <description>&lt;P&gt;Is there any way to create a “Background Process” through the Revit API?&amp;nbsp; Such as when you run a “Systems Analysis”?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ideal workflow:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;User Clicks a button in the current document. The background process starts and gives control back to the user.&lt;/LI&gt;&lt;LI&gt;The background process starts that creates a new document, links in the current document, and performs API tasks in the new document, saves and closes the new document.&lt;/LI&gt;&lt;LI&gt;When the tasks are completed, other API tasks are performed in the current document (nice, but not necessary, I can get around this requirement).&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;If this isn’t accessible through the API is there another way to do this through Autodesk Platform Services (Forge) or something?&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="KevinLawsonPE_0-1683053315979.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1209689i90CB52DFEC93126B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="KevinLawsonPE_0-1683053315979.png" alt="KevinLawsonPE_0-1683053315979.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 02 May 2023 18:49:28 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/background-process-api-access/m-p/11937077#M12260</guid>
      <dc:creator>Kevin.Lawson.PE</dc:creator>
      <dc:date>2023-05-02T18:49:28Z</dc:date>
    </item>
    <item>
      <title>Re: Background Process API Access?</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/background-process-api-access/m-p/11937960#M12261</link>
      <description>&lt;P&gt;Dear Kevin,&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;&lt;/P&gt;
&lt;P&gt;What you describe is completely impossible, if you take it word by word, because the Revit API and the interaction between Revit.exe and the API is single-threaded. All Revit API interaction requires a valid Revit API context, and that is only provided by Revit itself, and only within an event handler callback function such as the external command Execute method. So, no API interaction in a background process:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;A href="http://thebuildingcoder.typepad.com/blog/2015/08/revit-api-context-and-form-creation-errors.html#2" target="_blank"&gt;http://thebuildingcoder.typepad.com/blog/2015/08/revit-api-context-and-form-creation-errors.html#2&lt;/A&gt;&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But: the workflow you describe can very well be achieved anyway, more or less, depending on how much background processing you require, and especially how much of that background processing is really heavy-duty Revit API interaction.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can run any and all non-API interaction in the background with no problem. Then, when that is completed, you can switch back into a valid Revit API context by setting up an external event. External events are the key for interacting between a non-modal context (your background process) and the modal Revit API context.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Lots of examples are given by The Building Coder:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;A href="https://thebuildingcoder.typepad.com/blog/about-the-author.html#5.28" target="_blank"&gt;https://thebuildingcoder.typepad.com/blog/about-the-author.html#5.28&lt;/A&gt;&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Next: can this be achieved with APS, the Autodesk platform services (formerly Forge)?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Yes, absolutely. Using the APS Design Automation for API, you can automate any and all Revit API interaction that does not require any interaction with the Revit UI. To prepare for such a step, you can split your existing Revit desktop add-in into two parts:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;One part referencing RevitAPIUI.dll and implementing the UI&amp;nbsp;&lt;/LI&gt;
&lt;LI&gt;One part not&amp;nbsp;referencing RevitAPIUI.dll, only RevitAPI.dll, using only the DB part of the API&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The latter part can be migrated to APS Design Automation. Here are some examples of that process:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;A href="https://thebuildingcoder.typepad.com/blog/about-the-author.html#5.55" target="_blank"&gt;https://thebuildingcoder.typepad.com/blog/about-the-author.html#5.55&lt;/A&gt;&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Good luck and much success,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jeremy&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 03 May 2023 06:33:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/background-process-api-access/m-p/11937960#M12261</guid>
      <dc:creator>jeremy_tammik</dc:creator>
      <dc:date>2023-05-03T06:33:31Z</dc:date>
    </item>
    <item>
      <title>Re: Background Process API Access?</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/background-process-api-access/m-p/11938784#M12262</link>
      <description>&lt;P&gt;As always, thank you!&amp;nbsp; It looks like it's time to start digging into APS.&lt;/P&gt;</description>
      <pubDate>Wed, 03 May 2023 13:30:27 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/background-process-api-access/m-p/11938784#M12262</guid>
      <dc:creator>Kevin.Lawson.PE</dc:creator>
      <dc:date>2023-05-03T13:30:27Z</dc:date>
    </item>
  </channel>
</rss>

