BackGroundWorker.DoWork with Revit API

talbimam
Contributor
Contributor

BackGroundWorker.DoWork with Revit API

talbimam
Contributor
Contributor

i'm trying to make a progress bar to a relatively long process (that needs a nested loop) when i use the same code without the Revit API (simulation) the whole systeme work fine and the progress is reported but when i include the real code (Revit API with transaction and other API methods) the code compile without any errors but it did not works (the UI button don't run the bunch of code inside the DoWork method) and all the code is worthless.

please if anyone can give a hint, thanks

0 Likes
Reply
864 Views
1 Reply
Reply (1)

jeremytammik
Autodesk
Autodesk

I assume you are aware that the Revit API is single threaded and requires a valid Revit API context?

 

Such a context is only provided within the event handlers for the events provided by the Revit API.

 

https://thebuildingcoder.typepad.com/blog/2015/08/revit-api-context-and-form-creation-errors.html#2

 

Many of the articles on driving Revit from outside explain various aspects of this:

 

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

 

That said, solutions for displaying a progress bar in parallel with Revit API processing have been presented here in the past; just search this forum for 'progress bar' and you will find them.

   



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes