Dev > Team

Extension Manager

Installs, updates and removes pyNavis extensions listed in your team registry. Shift+Click sets the registry.

Tab and panelDev > Team
KindButton

Status

Untested Never executed inside Navisworks. Passed the headless checks only.

The public ask

No public source is on record for this tool.

Events it listens to

None. It runs only when you click it.

Files

Paths are relative to the Playground.extension folder.

  • Dev.tab/Team.panel/Extension_Manager.pushbutton/bundle.yaml
  • Dev.tab/Team.panel/Extension_Manager.pushbutton/config.py
  • Dev.tab/Team.panel/Extension_Manager.pushbutton/icon.dark.png
  • Dev.tab/Team.panel/Extension_Manager.pushbutton/icon.png
  • Dev.tab/Team.panel/Extension_Manager.pushbutton/icon.small.dark.png
  • Dev.tab/Team.panel/Extension_Manager.pushbutton/icon.small.png
  • Dev.tab/Team.panel/Extension_Manager.pushbutton/script.py

Install

  1. Only this tool. In Navisworks, click pyNavis > Playground, search for Extension Manager, tick it and click Install.
  2. The whole extension. Download Playground.extension.zip, unzip it, put the Playground.extension folder in %APPDATA%\pyNavis\extensions\, and click pyNavis > Reload. Extension Manager is on the Dev tab, Team panel.

You need pyNavis 1.3.0 or later.

Tried it? Tell us whether it worked or not. That report is what moves a tool up the status ladder.

Report

Source

The tool's own files, word for word as published in pynavis/Playground. Paths are relative to the Playground.extension folder.

script.py

The script that runs on a click.

Dev.tab/Team.panel/Extension_Manager.pushbutton/script.py View on GitHub
# -*- coding: utf-8 -*-
"""Installs, updates and removes pyNavis extensions from the team registry."""
import os
import tempfile

from pynavis import script, toast

from namo import buttonmaker, extmanager, hotkeys, paths, progress, ribbon


def run():
    cfg = script.get_config({'registry': ''})
    location = (cfg['registry'] or '').strip() or extmanager.default_registry(paths.team_root())
    user_root = buttonmaker.user_root()
    entries, problems, notice = [], [], None
    if location == extmanager.PLACEHOLDER:
        notice = 'No registry is set. Shift+Click Extension Manager to choose one.'
    else:
        try:
            outcome = progress.run('Reading the extension registry',
                                   lambda report: extmanager.load_registry(location), 'Reading')
        except IOError as error:
            notice = str(error)
        else:
            if outcome is progress.CANCELLED:
                return                              # cancelled: say nothing
            entries, problems = outcome
    roots = [user_root]
    config_root, _error = hotkeys.read_config(ribbon.user_config_path())
    for root in (config_root or {}).get('extensions') or []:
        if isinstance(root, str) and root.strip() and root.strip().lower() != user_root.lower():
            roots.append(root.strip())
    temp_folder = os.path.join(tempfile.gettempdir(), 'playground-extensions')
    changed = extmanager.run_window(location, entries, problems, user_root, roots,
                                    os.path.join(paths.data_root(), 'trash'), temp_folder, notice)
    if changed:
        ribbon.reload()
        toast.success('Reloaded pyNavis', '%d extension%s changed.' % (changed, '' if changed == 1 else 's'))


if globals().get('__runner__'):
    toast.info('The Extension Manager needs the Navisworks window', 'It cannot open under pynavis run.')
else:
    run()

config.py

The Shift+Click action.

Dev.tab/Team.panel/Extension_Manager.pushbutton/config.py View on GitHub
# -*- coding: utf-8 -*-
"""Sets where the Extension Manager reads its registry of extensions."""
import os
import re

from pynavis import script, toast

from namo import extmanager, paths, ui

cfg = script.get_config({'registry': ''})
default = extmanager.default_registry(paths.team_root())


def check(values):
    location = (values.get('registry') or '').strip()
    if location and not re.match(r'^https?://', location, re.IGNORECASE) and not os.path.isfile(location):
        return {'registry': 'Give a web address (https://...) or a JSON file that exists.'}
    return {}


values = ui.form('Extension Manager', [
    {'kind': 'text', 'key': 'registry', 'label': 'Registry (URL or JSON file)', 'default': cfg['registry'],
     'placeholder': default if default != extmanager.PLACEHOLDER else 'https://intranet/pynavis/registry.json',
     'hint': 'Blank uses extension-registry.json in the team folder when there is one.'},
], intro='The registry lists extensions as {"extensions": [{"name", "version", "download", ...}]}.',
    ok='Save', validate=check)
if values is not None:
    script.save_config({'registry': (values['registry'] or '').strip()})
    toast.success('Registry saved', (values['registry'] or '').strip() or 'Using the team folder default.')

Library modules this tool uses

From the shared namo library, which installs with every tool. Each name opens the module on GitHub.

  • namo.buttonmakerButton Maker: writes new pyNavis bundles into the user's own extension.
  • namo.extmanagerExtension Manager: install, update and remove pyNavis extensions from a registry.
  • namo.hotkeysHotkey Manager: one list of every command, with chords you can assign or clear.
  • namo.pathsWhere Playground keeps its files, and how it writes them safely.
  • namo.progressGlue between pyNavis' cancellable progress window and Playground's progress callbacks.
  • namo.ribbonThe ribbon as data: every pyNavis button and every native Navisworks command, and safe ways to run them from code. Shared by the Command Palette, macros, the Hotkey Manager, usage analytics and the Environment Doctor.
  • namo.uiWPF building blocks for Playground tools, themed from the pyNavis design system.

bundle.yaml

The bundle contract: the keys pyNavis reads for this tool.

Dev.tab/Team.panel/Extension_Manager.pushbutton/bundle.yaml View on GitHub
title: Extension\nManager
tooltip: Installs, updates and removes pyNavis extensions listed in your team registry. Shift+Click sets the registry.