<?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: Revit 2015 InternalException on CustomExporter with Linked Files in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/revit-2015-internalexception-on-customexporter-with-linked-files/m-p/4996056#M76895</link>
    <description>&lt;DIV&gt;&lt;FONT color="#000000"&gt;Yes, that is unfortunate but correct: Revit does not reach out to external applications while a perspective view is active. External Events are not invoked and so isn’t anything else (external commands, events, etc.) That is a legacy limitation that has been in the Revit API since its inception. The reason for it is that, historically, most of the functions in Revit was disabled&amp;nbsp;in&amp;nbsp;perspective&amp;nbsp;views, and the development team woried that by opening functions via the API we would have allowed workflows that had not really been covered by any tests. It is possible that this threat&amp;nbsp;&amp;nbsp;does not have any merits anymore, the limitation is still in place, however, as R2015 goes. We have been talking about&amp;nbsp;taking&amp;nbsp;it out&amp;nbsp;for R2016 (a tasks already exists for it,) but it remains to be seen if we actually do it.&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT color="#000000"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT color="#000000"&gt;That’s for the technical background in case you are interested to hear the details. As for the “newly imposed limitations” and “it’s working in 2014”, I would argue about that. The fact is that we have not imposed any limitation regarding either perspective views or accessing Revit from outside threads. It has never been possible to run the API while in perspective views. And we have always tried to make it clear that accessing Revit &amp;nbsp;from outside threads is not supported and definitely not recommended. (I myself had presentations about that very topic at two different AU events and on another DevCamp event, plus wrote some documentation that circles around.) The claim itself that “it works in 2014” needs to be taken cautiously. While I do not doubt it works on your machine and probably for some of your users as well, I can practically guarantee that accessing the Revit API will crash some users’ session eventually no matter what version of Revit they run&amp;nbsp;– that fact is virtually certain.&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;
&lt;DIV&gt;&lt;FONT color="#000000"&gt;There is a workaround for this limitation, albeit I must admit it is not very elegant. Perspective views (and any 3D views) can be exported using Custom Exporters, but the export must start when the perspective view is not the active view. I do realize that it is kind of silly, however,&amp;nbsp;that is the limitation we have in place now. Sorry about that. &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&amp;nbsp;I would suggest that the&amp;nbsp;application that export views is added to Revit as an external command. That command would be disabled in perspective views similarly to other commands, thus it should be not very surprising for the end user. And when the user is able to invoked the command (in a different view), the application can present him or her with a list of views to be exported,&amp;nbsp;which may contain perspective views as well.&lt;/FONT&gt;&lt;/DIV&gt;
&lt;/DIV&gt;</description>
    <pubDate>Mon, 28 Apr 2014 13:19:31 GMT</pubDate>
    <dc:creator>arnostlobel</dc:creator>
    <dc:date>2014-04-28T13:19:31Z</dc:date>
    <item>
      <title>Revit 2015 InternalException on CustomExporter with Linked Files</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/revit-2015-internalexception-on-customexporter-with-linked-files/m-p/4993730#M76892</link>
      <description>&lt;P&gt;CustomExporter.export is crashing on Revit 2015 when run in a spearate thread when there are linked files in the scene.&amp;nbsp; Works fine on Revit 2014.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The code to reproduce this is....&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;        public class MyExportContext2 : IExportContext
        {

            public MyExportContext2()
            {
            }

            public void OnPolymesh(PolymeshTopology node)
            {
            }

            public void OnMaterial(MaterialNode node)
            {
            }

            public void Finish()
            {
            }

            public bool IsCanceled()
            {
                return false;
            }

            public void OnDaylightPortal(DaylightPortalNode node)
            {
            }

            public void OnLight(LightNode node)
            {
            }

            public RenderNodeAction OnLinkBegin(LinkNode node)
            {
                return RenderNodeAction.Proceed;
            }

            public void OnLinkEnd(LinkNode node)
            {
            }

            public void OnRPC(RPCNode node)
            {
            }

            public RenderNodeAction OnViewBegin(ViewNode node)
            {
                return RenderNodeAction.Proceed;
            }

            public void OnViewEnd(ElementId elementId)
            {
            }

            public RenderNodeAction OnFaceBegin(FaceNode node)
            {
                return RenderNodeAction.Proceed;
            }

            public void OnFaceEnd(FaceNode node)
            {
            }

            public RenderNodeAction OnElementBegin(ElementId elementId)
            {
                return RenderNodeAction.Proceed;
            }

            public void OnElementEnd(ElementId elementId)
            {
            }

            public RenderNodeAction OnInstanceBegin(InstanceNode node)
            {
                return RenderNodeAction.Proceed;
            }

            public void OnInstanceEnd(InstanceNode node)
            {
            }

            public bool Start()
            {
                return true;
            }
        }&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;and to call it....&lt;/P&gt;&lt;PRE&gt;       class MyEventHandler : IExternalEventHandler 
        {
            public void RunExporter()
            {
                MyExportContext2 m_ExportContext = null;
                m_ExportContext = new MyExportContext2();
                CustomExporter exporter = new CustomExporter(HostManager.GetCurrentDocument(), m_ExportContext);
                View3D m_ActiveView = HostManager.GetCurrentDocument().ActiveView as View3D;
                exporter.Export(m_ActiveView);
            }

            public void Execute(UIApplication a)
            {
                if (!HostManager.IsCurrentView3dPerspective())
                {
                    SelectViewForm f = new SelectViewForm();
                    f.ShowDialog();
                }

                Thread thread = new Thread(this.RunExporter);
                thread.Start();
            }
...etc&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;Paul&lt;/P&gt;</description>
      <pubDate>Sun, 27 Apr 2014 01:19:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/revit-2015-internalexception-on-customexporter-with-linked-files/m-p/4993730#M76892</guid>
      <dc:creator>pfk</dc:creator>
      <dc:date>2014-04-27T01:19:59Z</dc:date>
    </item>
    <item>
      <title>Re: Revit 2015 InternalException on CustomExporter with Linked Files</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/revit-2015-internalexception-on-customexporter-with-linked-files/m-p/4994376#M76893</link>
      <description>&lt;P&gt;&lt;FONT face="Times New Roman" color="#000000"&gt;Oh, now we can see the problem clear. Paul,&amp;nbsp;&lt;STRONG&gt;Revit API must not be accessed from other than the main thread&lt;/STRONG&gt;! We (in Revit) do not support invoking API methods from other thread. In fact, it is the main purpose of the External Event mechanism to allow external out-of-thread processing to access the Revit API on demand at semi-random times. The External Event allows the user to signal the event (and that is done in a thread-safe manner). Once an external event is signaled, Revit will pick it up when ready and will call the event;s handler back. In the handler the user can do whatever he or she wants as long as he/she stays on the same thread. Again,&amp;nbsp;&lt;STRONG&gt;communicating with the API from an outside thread is prohibited&lt;/STRONG&gt;.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Times New Roman" color="#000000"&gt;I think we have out mystery explained. I sort of suspected something like this when I saw your first post in the other thread. I hinted you that it looked like you addressed the API illegally and recommended the External Event mechanism. However, when you posted that you refactored your code using External Events I thought the thread were under control.&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Times New Roman" color="#000000"&gt;Thank you&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Times New Roman" color="#000000"&gt;Arnošt Löbel&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Times New Roman" color="#000000"&gt;Sr. Principal Engineer&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Times New Roman" color="#000000"&gt;Autodesk, Revit R&amp;amp;D&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 27 Apr 2014 20:03:25 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/revit-2015-internalexception-on-customexporter-with-linked-files/m-p/4994376#M76893</guid>
      <dc:creator>arnostlobel</dc:creator>
      <dc:date>2014-04-27T20:03:25Z</dc:date>
    </item>
    <item>
      <title>Re: Revit 2015 InternalException on CustomExporter with Linked Files</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/revit-2015-internalexception-on-customexporter-with-linked-files/m-p/4995002#M76894</link>
      <description>This is very unfortunate news. These changes present immense difficulties&lt;BR /&gt;for my plugin. Converting the scene load call (CustomExporter) into an&lt;BR /&gt;ExternalEvent which is on the UI thread stops Revit crashing, however, an&lt;BR /&gt;ExternalEvent does not fire when the user is viewing a 3d perspective&lt;BR /&gt;window. So, the user cannot open the plugin rendering window for the Revit&lt;BR /&gt;perspective view they want to render whilst viewing that perspective view.&lt;BR /&gt;This is a impractical solution.&lt;BR /&gt;&lt;BR /&gt;To re-iterate, the plugin works perfectly on Revit 2014. But at this stage&lt;BR /&gt;looks non-viable for Revit 2015 with the new limitations which have been&lt;BR /&gt;imposed.&lt;BR /&gt;&lt;BR /&gt;Paul</description>
      <pubDate>Mon, 28 Apr 2014 07:49:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/revit-2015-internalexception-on-customexporter-with-linked-files/m-p/4995002#M76894</guid>
      <dc:creator>pfk</dc:creator>
      <dc:date>2014-04-28T07:49:59Z</dc:date>
    </item>
    <item>
      <title>Re: Revit 2015 InternalException on CustomExporter with Linked Files</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/revit-2015-internalexception-on-customexporter-with-linked-files/m-p/4996056#M76895</link>
      <description>&lt;DIV&gt;&lt;FONT color="#000000"&gt;Yes, that is unfortunate but correct: Revit does not reach out to external applications while a perspective view is active. External Events are not invoked and so isn’t anything else (external commands, events, etc.) That is a legacy limitation that has been in the Revit API since its inception. The reason for it is that, historically, most of the functions in Revit was disabled&amp;nbsp;in&amp;nbsp;perspective&amp;nbsp;views, and the development team woried that by opening functions via the API we would have allowed workflows that had not really been covered by any tests. It is possible that this threat&amp;nbsp;&amp;nbsp;does not have any merits anymore, the limitation is still in place, however, as R2015 goes. We have been talking about&amp;nbsp;taking&amp;nbsp;it out&amp;nbsp;for R2016 (a tasks already exists for it,) but it remains to be seen if we actually do it.&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT color="#000000"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT color="#000000"&gt;That’s for the technical background in case you are interested to hear the details. As for the “newly imposed limitations” and “it’s working in 2014”, I would argue about that. The fact is that we have not imposed any limitation regarding either perspective views or accessing Revit from outside threads. It has never been possible to run the API while in perspective views. And we have always tried to make it clear that accessing Revit &amp;nbsp;from outside threads is not supported and definitely not recommended. (I myself had presentations about that very topic at two different AU events and on another DevCamp event, plus wrote some documentation that circles around.) The claim itself that “it works in 2014” needs to be taken cautiously. While I do not doubt it works on your machine and probably for some of your users as well, I can practically guarantee that accessing the Revit API will crash some users’ session eventually no matter what version of Revit they run&amp;nbsp;– that fact is virtually certain.&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;
&lt;DIV&gt;&lt;FONT color="#000000"&gt;There is a workaround for this limitation, albeit I must admit it is not very elegant. Perspective views (and any 3D views) can be exported using Custom Exporters, but the export must start when the perspective view is not the active view. I do realize that it is kind of silly, however,&amp;nbsp;that is the limitation we have in place now. Sorry about that. &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&amp;nbsp;I would suggest that the&amp;nbsp;application that export views is added to Revit as an external command. That command would be disabled in perspective views similarly to other commands, thus it should be not very surprising for the end user. And when the user is able to invoked the command (in a different view), the application can present him or her with a list of views to be exported,&amp;nbsp;which may contain perspective views as well.&lt;/FONT&gt;&lt;/DIV&gt;
&lt;/DIV&gt;</description>
      <pubDate>Mon, 28 Apr 2014 13:19:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/revit-2015-internalexception-on-customexporter-with-linked-files/m-p/4996056#M76895</guid>
      <dc:creator>arnostlobel</dc:creator>
      <dc:date>2014-04-28T13:19:31Z</dc:date>
    </item>
    <item>
      <title>Re: Revit 2015 InternalException on CustomExporter with Linked Files</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/revit-2015-internalexception-on-customexporter-with-linked-files/m-p/4998524#M76896</link>
      <description>Firstly - I appreciate the time and effort you are putting into providing&lt;BR /&gt;info on this issue.&lt;BR /&gt;&lt;BR /&gt;However, the outcome is that I have invested an incredible amount of time&lt;BR /&gt;in the plugin, which cannot be made to run viably in Revit 2015.&lt;BR /&gt;&lt;BR /&gt;The plugin has never crashed Revit 2014 to my knowledge. I've have no&lt;BR /&gt;users reports of crashes, and have spent countless hours using the plugin,&lt;BR /&gt;and never had a crash.&lt;BR /&gt;&lt;BR /&gt;When the plugin starts (in a 2d view), the plugin setup dialog opens, and&lt;BR /&gt;then the user opens the plugin rendering Viewport. At this stage, a 3d&lt;BR /&gt;perspective view is selected, and the plugin rendering Viewport tracks the&lt;BR /&gt;Revit 3d perspective view - moving as the user moves the Revit camera. If&lt;BR /&gt;the user then closes the plugin rendering Viewport, Revit is left in the 3d&lt;BR /&gt;perspective view - so under 2015 the user cannot then open the Viewport&lt;BR /&gt;again - they have to return back to a 2 view, then reselect the 3d view.&lt;BR /&gt;&lt;BR /&gt;Whilst the above is a serious limitation, a far greater problem is that&lt;BR /&gt;when the user has the plugin rendering viewport open, and they decide they&lt;BR /&gt;want to fresh the rendering geometry (which they would do on Revit 2014&lt;BR /&gt;frequently), under Revit 2015 they cannot - because they are currently&lt;BR /&gt;viewing a 3d perspective view.&lt;BR /&gt;&lt;BR /&gt;All the above working perfectly in Revit 2014 and never crashed.&lt;BR /&gt;&lt;BR /&gt;Paul</description>
      <pubDate>Tue, 29 Apr 2014 09:26:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/revit-2015-internalexception-on-customexporter-with-linked-files/m-p/4998524#M76896</guid>
      <dc:creator>pfk</dc:creator>
      <dc:date>2014-04-29T09:26:59Z</dc:date>
    </item>
    <item>
      <title>Re: Revit 2015 InternalException on CustomExporter with Linked Files</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/revit-2015-internalexception-on-customexporter-with-linked-files/m-p/4999092#M76897</link>
      <description>&lt;DIV&gt;&lt;FONT color="#000000"&gt;Paul,&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT color="#000000"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT color="#000000"&gt;I have thought about this a lot; not just the problem you’d reported, but others such similar cases as well. The truth is probably harsh for some, I admit, but we simply cannot afford making sure that unsupported workflows work the same from a version to another. We, Revit developers and software architects reserve the right to improve and modify our software to the best benefit of users who use it the standard and supported way. Not only we do not recommend (and do no agree with) users to use unsupported workflows, such as calling to the API from work threads,&amp;nbsp;but we also do not have such workflows covered by any of our regression tests, quite naturally I’d say. That is why, of course, we would not even notice when we add, by&amp;nbsp;coincidence,&amp;nbsp;a road-block to some of the unsupported work-flows. I’d hope all this what I am saying should be understood by a reasonable person particularly one that has some clues about how software development works. We have almost twenty thousand tests which we run several times a day to make sure we keep the quality of our software high.&amp;nbsp;That’s to say we really are carefully watching we do not impose any new limitations and/or regressions by any of our incremental changes to Revit (although it does happen sometimes, unfortunately). Regression of unsupported features is not the focus of our quality goals in any&amp;nbsp;way though and,&amp;nbsp;like I stated already, we do not have any tests for it.&amp;nbsp;&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT color="#000000"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT color="#000000"&gt;As for the crashing or not crashing: Paul, you can swear to me that your app never crashes, and who knows, you may be the lucky one, but I bet you good money that I’d be able to write a perfectly legal Revit add-in (which would not use any nonstandard ways) that would either crash your application or would be crashed by it. Like I said, a crash is virtually guaranteed&amp;nbsp;– it only depends on the number of customers you distribute your add-in to, and&amp;nbsp;other addins&amp;nbsp;those customers have&amp;nbsp;installed&amp;nbsp;on their respective computers with Revit.&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT color="#000000"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT color="#000000"&gt;However, even if no crash is actually experienced, there is still the problem of using wrong data by your add-in. You export 3D views, which is a process that may take minutes. During the export there may be other (legally working) applications running in Revit and Revit would allow them to run since Revit does not know about your application&amp;nbsp;actively exporting. Now, those other applications are, naturally, allowed to modify the model your application is in the middle of exporting of. When that happens, assuming it does not crash either your or the other applications, your export would suddenly be exporting inconsistent data, since the model is not what it was when the export started.&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT color="#000000"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT color="#000000"&gt;So, even knowing I may hurt someone’s feelings and make one upset, I have to be firm about this: Revit does not support unsupported features and does not guarantee they will behave the same way from a version to the next.&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT color="#000000"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT color="#000000"&gt;However, we naturally want to improve on&amp;nbsp;the features we have and that includes our API. The request for allowing the API be functional in perspective views has been logged many times and its resolution is, in my opinion, long overdue. I promise I will put my very strong word for it to happen in R2016 and I hope that limitation will be lifted.&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT color="#000000"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT color="#000000"&gt;Respectfully,&lt;/FONT&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 29 Apr 2014 13:22:23 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/revit-2015-internalexception-on-customexporter-with-linked-files/m-p/4999092#M76897</guid>
      <dc:creator>arnostlobel</dc:creator>
      <dc:date>2014-04-29T13:22:23Z</dc:date>
    </item>
    <item>
      <title>Re: Revit 2015 InternalException on CustomExporter with Linked Files</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/revit-2015-internalexception-on-customexporter-with-linked-files/m-p/5053252#M76898</link>
      <description>&lt;P&gt;I have a similar problem. This API change is not too good. A new thread divided transaction system would be a better idea than this.&lt;BR /&gt;&lt;BR /&gt;Have a nice day!&lt;BR /&gt;&lt;BR /&gt;David Schmidt&lt;/P&gt;</description>
      <pubDate>Fri, 23 May 2014 14:53:34 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/revit-2015-internalexception-on-customexporter-with-linked-files/m-p/5053252#M76898</guid>
      <dc:creator>Sydra7</dc:creator>
      <dc:date>2014-05-23T14:53:34Z</dc:date>
    </item>
  </channel>
</rss>

