pyNavis panel

Hide Tabs

Take the tabs you choose off the ribbon for a clean screen, a recording or a demo, and put them back with the next click.

On the ribbonToggle, pyNavis panel
NeedsNothing
Shift+ClickWhich tabs to take off

What it does#

A ribbon collects a tab for every add-in ever installed, and a screen recording or a demo does not need them. Navisworks can untick a tab from the ribbon's right-click Show Tabs, but an add-in's tab comes straight back: Navisworks re-shows every add-in tab each time it is idle. This takes the tabs out of the ribbon altogether, so they stay gone, and puts each one back where it was.

How to use it#

  1. Shift+Click Hide Tabs and tick the tabs to take off. The list opens with your last choice already ticked.
  2. Click Hide Tabs. The tabs leave the ribbon, the button is pressed and now reads Show Tabs, and a toast names what went.
  3. Click Show Tabs to bring them back, each in its old place.

Limitations#

  • The tabs Navisworks opens on its own, Item Tools, Sectioning Tools and Recording, are not offered: taking one out would stop it opening when it is needed. Neither are the pyNavis tabs, since one of them holds this button.
  • Hiding lasts for the session. Navisworks starts with every tab, and the tabs go back just before Navisworks closes, so its own saved ribbon layout never loses them.

Good to know#

The choice is stored in hide_tabs.json by tab id. A tab whose add-in is no longer loaded is skipped rather than forgotten, so it is hidden again once the add-in is back. Reload does not bring hidden tabs back; the button does.

Source#

The tool's own files, word for word as shipped in pyNavis.panel/Hide_Tabs.toggle. Every pyNavis tool is an ordinary bundle: copy these into your own extension and change what you like.

script.py Runs on a click. View on GitHub
"""Takes the chosen tabs off the ribbon, or puts them back.

What is off the ribbon decides, not the button's own on/off state, so the
two can never disagree: tabs off means this click puts them back, anything
else means it takes them off. With no chosen tab on the ribbon, the picker
opens first (the Shift+Click one). The tabs stay off for the session and
go back when Navisworks closes (hooks/app-closing.py). See lib/tabhider.py.
"""

import tabhider

from pynavis import script, settings, toast


def run():
    if tabhider.hidden():
        count = tabhider.show()
        script.set_toggle_state(False)
        toast.info(tabhider.shown_message(count))
        return

    chosen = settings.load(tabhider.TOOL, tabhider.DEFAULTS)['tabs']
    if not tabhider.to_hide(tabhider.tab_list(), chosen):
        chosen = tabhider.choose()
        if chosen is None:
            script.set_toggle_state(False)
            return                          # cancelled: say nothing
    titles = tabhider.hide(chosen)
    script.set_toggle_state(bool(titles))
    if titles:
        title, detail = tabhider.hidden_message(titles)
        toast.success(title, detail)


run()
config.py Runs on Shift+Click. View on GitHub
"""Chooses which tabs Hide Tabs takes off the ribbon.

Tabs that are off the ribbon cannot be picked, so while they are off they
go back for the picker and come off again afterwards: with the new choice
when there is one, with the old one on cancel.
"""

import tabhider

from pynavis import script, settings, toast

was_hidden = tabhider.hidden()
if was_hidden:
    tabhider.show()

chosen = tabhider.choose()
if was_hidden:
    tabhider.hide(chosen if chosen is not None
                  else settings.load(tabhider.TOOL, tabhider.DEFAULTS)['tabs'])
    script.set_toggle_state(tabhider.hidden())

if chosen is not None:                     # None means cancelled: say nothing
    count = '%d tab%s' % (len(chosen), '' if len(chosen) == 1 else 's')
    if was_hidden:
        toast.success('Saved', 'The new choice of %s is off the ribbon now.' % count)
    else:
        toast.success('Saved', 'Click Hide Tabs to take off the %s you chose.' % count)
bundle.yaml The bundle contract: the keys pyNavis reads for this tool. View on GitHub
title: Hide\nTabs
title_on: Show\nTabs
tooltip: Takes the tabs you choose off the ribbon for a clean screen, a recording or a demo, and puts them back when you click again. Add-in tabs too, which the ribbon's own Show Tabs cannot keep hidden. Everything comes back when Navisworks closes. Shift+Click to choose the tabs.
tooltip_on: Puts the tabs you hid back on the ribbon, each where it was. Shift+Click to change which tabs are hidden.