Dec 20, 2020
Update ProjectBrowser with RevitAPI
Have you ever changed SheetNumber with RevitAPI to find out that nothing happens, at least visually? Revit does not update ProjectBrowser after SheetNumber change. So we have to do it manually.
SheetNumber does not update.
You have probably made your script to change SheetNumber with RevitAPI but nothing happened after running your script.
As usual, you open your code and look for clues what could have gone wrong and probably find nothing...
This happens because ProjectBrowser does not update itself after SheetNumber is changed with your code. Hopefully, in the near future, someone from Autodesk will solve it, but for now, we have to do it ourselves.
When I first encountered this behavior, I thought my code was wrong.
Hopefully, quite soon I have noticed with my test print() statements that actually it changes SheetNumber but does not display new SheetNumber in the ProjectBrowser.
After trial and error, I have discovered that hiding and reopening Project Browser solved the issue. The question now, how do we solve it in the code so our users won't panic and click on the button over and over hoping for better results?
This is very simple. All we need to do is to find our ProjectBrowser in BuiltInDockablePanes, use
Hide() and execute your code for changing SheetNumber and then bring it back with
Show() so people won't get scared that their ProjectBrowser has disappeared.
Here is a snippet below: