<?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 How to run the export method asynchronously in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/how-to-run-the-export-method-asynchronously/m-p/11093330#M19746</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I am doing Revit plugin which contains method that exports document to IFC. The thing I don't like is that the export takes several seconds and from my point of view it can be little bit confusing for users to find out if the file is actually exporting (I was confused as well for the first time), because Revit shows only little note in bottom left corner which can be very easily missed. So I wanted to run the export method asynchronously and show WPF window, which would say to user, that file is exporting in the mean-time. But I haven't found any way to achieve this.&lt;/P&gt;&lt;P&gt;Here is what I've already tried:&lt;/P&gt;&lt;P&gt;I have standard execute method.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {

            UIApplication uiapp = commandData.Application;
            Document doc = uiapp.ActiveUIDocument.Document;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then I would like to run export and show the WPF window (Upload) during the export saying something like "Exporting in progress...".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;            Transaction trans = new Transaction(doc);
            trans.Start("Lab");
            ThreadStart starterOne = delegate { ExportParallel(ref doc, ref trans, folderPath, file); };
            Thread thread = new Thread(starterOne);
            thread.Start();


            Upload uploadTest = new Upload();
            uploadTest.ShowDialog();&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;And here is my ExportParallel method&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;        public void ExportParallel(ref Document doc, ref Transaction trans, string folderPath, string file)
        {
            doc.Export(folderPath, file, new IFCExportOptions());
            trans.Commit();
        }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anyone have any idea, how can I achieve this? I am still getting error "Autodesk.Revit.Exceptions.InternalException: 'Restriction not handled" on the doc.Export() line...&lt;/P&gt;&lt;P&gt;Thank you very much&lt;/P&gt;&lt;P&gt;Have a great day&lt;/P&gt;&lt;P&gt;Jan&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 08 Apr 2022 13:28:40 GMT</pubDate>
    <dc:creator>smutnyENWWU</dc:creator>
    <dc:date>2022-04-08T13:28:40Z</dc:date>
    <item>
      <title>How to run the export method asynchronously</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/how-to-run-the-export-method-asynchronously/m-p/11093330#M19746</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I am doing Revit plugin which contains method that exports document to IFC. The thing I don't like is that the export takes several seconds and from my point of view it can be little bit confusing for users to find out if the file is actually exporting (I was confused as well for the first time), because Revit shows only little note in bottom left corner which can be very easily missed. So I wanted to run the export method asynchronously and show WPF window, which would say to user, that file is exporting in the mean-time. But I haven't found any way to achieve this.&lt;/P&gt;&lt;P&gt;Here is what I've already tried:&lt;/P&gt;&lt;P&gt;I have standard execute method.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {

            UIApplication uiapp = commandData.Application;
            Document doc = uiapp.ActiveUIDocument.Document;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then I would like to run export and show the WPF window (Upload) during the export saying something like "Exporting in progress...".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;            Transaction trans = new Transaction(doc);
            trans.Start("Lab");
            ThreadStart starterOne = delegate { ExportParallel(ref doc, ref trans, folderPath, file); };
            Thread thread = new Thread(starterOne);
            thread.Start();


            Upload uploadTest = new Upload();
            uploadTest.ShowDialog();&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;And here is my ExportParallel method&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;        public void ExportParallel(ref Document doc, ref Transaction trans, string folderPath, string file)
        {
            doc.Export(folderPath, file, new IFCExportOptions());
            trans.Commit();
        }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anyone have any idea, how can I achieve this? I am still getting error "Autodesk.Revit.Exceptions.InternalException: 'Restriction not handled" on the doc.Export() line...&lt;/P&gt;&lt;P&gt;Thank you very much&lt;/P&gt;&lt;P&gt;Have a great day&lt;/P&gt;&lt;P&gt;Jan&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Apr 2022 13:28:40 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/how-to-run-the-export-method-asynchronously/m-p/11093330#M19746</guid>
      <dc:creator>smutnyENWWU</dc:creator>
      <dc:date>2022-04-08T13:28:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to run the export method asynchronously</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/how-to-run-the-export-method-asynchronously/m-p/11093516#M19747</link>
      <description>&lt;P&gt;Revit and its API is single threaded:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://thebuildingcoder.typepad.com/blog/2011/06/no-multithreading-in-revit.html" target="_blank"&gt;http://thebuildingcoder.typepad.com/blog/2011/06/no-multithreading-in-revit.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As long as it is busy exporting, it will be blocked.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can certainly disconnect your WPF UI from Revit to let the user do other things.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, it is impossible to do other things with Revit as long as it is busy with its job.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Apr 2022 14:35:26 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/how-to-run-the-export-method-asynchronously/m-p/11093516#M19747</guid>
      <dc:creator>jeremy_tammik</dc:creator>
      <dc:date>2022-04-08T14:35:26Z</dc:date>
    </item>
  </channel>
</rss>

