Announcements
Autodesk Community will be read-only between April 26 and April 27 as we complete essential maintenance. We will remove this banner once completed. Thanks for your understanding

Internal Exception: Downloading File From Server and the Opening that file

ariWZRFQ
Enthusiast

Internal Exception: Downloading File From Server and the Opening that file

ariWZRFQ
Enthusiast
Enthusiast

Hello,

 

I am writing an external command to download a revit file from a remote server to the local machine and then open that file to interact with it. The code is very simple and generally flows like below.

 

Send HTTP get request to remote server, server sends back download urls, code downloads the revit files from those urls into the local temp directory, then call app.OpenDocumentFile(path).

 

The app.OpenDocumentFile(path) causes an internal exception in Revit. Both parts of the code work correctly when unlinked, ie, I can comment out the openDocument code and the files download properly, then I can comment out the download code and the recently downloaded files open properly. When I try to call the functions one after the other in the same external command is where the internal exception occurs.

 

Any ideas or help would be greatly appreciated. Thanks

 

0 Likes
Reply
Accepted solutions (1)
580 Views
4 Replies
Replies (4)

jeremy_tammik
Autodesk
Autodesk
Accepted solution

I have no idea what the problem might be, but I do have a suggestion on how you can quite disconnect the two operations from one another to achieve a similar independence as if you were launching each in its own separate external command: run the first part of your workflow in its own external command. Just before you return from that command, subscribe to the Idling event:

 

https://www.revitapidocs.com/2023/e233027b-ba8c-0bd1-37b7-93a066efa5a3.htm

 

You can even specify that it should be called once only. 

 

In the event handler, unsubscribe from the event again and perform your second processing step. The event handler has its own independent context and is disconnected from the first external command, so you should observe the same beneficial effect.

  

Of course, a much better solution would be to fix the problem instead of working around the symptom.

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open

ariWZRFQ
Enthusiast
Enthusiast

Thank you Jeremy,

 

I will look into that work around today and see if I can get it to work.

 

Is there any more information I can provide that would help diagnose the root of problem? I feel that I have extracted as much information as I can out of it to narrow it down but am happy to run a few more tests or anything to help solve it.

 

Thanks

0 Likes

jeremy_tammik
Autodesk
Autodesk

If you were absolutely certain that your add-in is behaving impeccably and there is a serious error in Revit that cannot be worked around, I would ask for a minimal reproducible case to enable the development team to analyse it themselves:

  

https://thebuildingcoder.typepad.com/blog/about-the-author.html#1b

  

However, waiting for a fix might take a long time, so I would suggest trying other approaches first.

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes

ariWZRFQ
Enthusiast
Enthusiast

Thank you, 

 

I will submit a minimum reproducible case but will try the workaround to solve my problem in the meantime. 

 

Thank you for your time and insight.

0 Likes