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 with SheetNumber change. I will show you how.
SheetNumber does not update.
You have probably made your script to change SheetNumber with RevitAPI but nothing happened after running your script. Habitually, you open your code and look for clues that 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 faulty. 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:
from Autodesk.Revit.UI import DockablePanes, DockablePane project_browser_id = DockablePanes.BuiltInDockablePanes.ProjectBrowser project_browser = DockablePane(project_browser_id) project_browser.Hide() # change 'ViewSheet.SheetNumber' here project_browser.Show()
📩 Join Revit API Newsletter
Meanwhile, you will be receiving Newsletter with useful Tips & Tricks for Revit API
🙌 Thank You!
Confirm Your Email.
Check your inbox, you should receive a confirmation email to be added to the list.
📅 I usually send out my emails on Sundays, see you then👋