pyrevitlabs / pyRevit

Rapid Application Development (RAD) Environment for Autodesk Revit®
http://wiki.pyrevitlabs.io
GNU General Public License v3.0
1.33k stars 338 forks source link

Package Manager: Hide Tab After Uninstall #121

Closed gtalarico closed 8 years ago

gtalarico commented 8 years ago

@eirannejad I was able to successfully hide/show tabs so we can clean them up after removing packages, which is a nice touch (uses tab name). (especially since for some reason, buttons are not being disabled for deleted packages even after reloading)

It uses the AdWindows.dll assembly. I am not sure if anything needs to be changed on the RPL, but on my end it's working out of the box. I added an exception handler just in case since I haven't tested it out.

https://www.dropbox.com/s/hf702cq0b427bxi/2016-08-27%2016-43-25.mp4?dl=0

Any concerns?

def toggle_tab(package_name, state):
    """ Needs AdWindows.dll"""
    try:
        clr.AddReference('AdWindows')
        from Autodesk.Windows import ComponentManager
    except Exception as errmsg:
        logger.warning('Could not access required DLL to hide/show tabs.')
    else:
        ribbon = ComponentManager.Ribbon
        for tab in ribbon.Tabs:
            if tab.Title == package_name:
                tab.IsVisible = state

Discussion: http://forums.autodesk.com/t5/revit-api/remove-or-hide-a-ribbon-tab/td-p/6043321

eirannejad commented 8 years ago

Amazing. Works perfectly under package manager...