Dev > Team

Team Sync

Pulls the team's templates, presets, rules, shortcuts and project settings from the team folder, or pushes yours to it.

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/Team_Sync.pushbutton/bundle.yaml
  • Dev.tab/Team.panel/Team_Sync.pushbutton/icon.dark.png
  • Dev.tab/Team.panel/Team_Sync.pushbutton/icon.png
  • Dev.tab/Team.panel/Team_Sync.pushbutton/icon.small.dark.png
  • Dev.tab/Team.panel/Team_Sync.pushbutton/icon.small.png
  • Dev.tab/Team.panel/Team_Sync.pushbutton/script.py

Install

  1. Only this tool. In Navisworks, click pyNavis > Playground, search for Team Sync, 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. Team Sync 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/Team_Sync.pushbutton/script.py View on GitHub
# -*- coding: utf-8 -*-
"""Pulls shared Playground settings from the team folder, or pushes this computer's to it."""
from pynavis import forms, toast

from namo import ribbon, teamsync, ui


def pick(initial):
    return forms.pick_folder(title='Team folder (the one that holds or will hold playground-team)',
                             initial=initial or None)


if globals().get('__runner__'):
    toast.info('Team Sync needs the Navisworks window', 'It cannot open under pynavis run.')
else:
    state = teamsync.load_state()
    folder = teamsync.team_folder(state)
    if not folder:
        folder = pick('')
        if folder is not None:
            state['team_folder'] = folder
            teamsync.save_state(state)
    while folder:
        found = teamsync.preview(folder)
        win = teamsync.build_window(folder, found, state)
        ui.show_modal(win)
        action = win.Tag.action
        if win.Tag.auto_pull != state.get('auto_pull'):
            state['auto_pull'] = win.Tag.auto_pull
            teamsync.save_state(state)
            if action is None:
                toast.info('Pull at startup is %s' % ('on' if state['auto_pull'] else 'off'))
        if action == 'folder':
            chosen = pick(folder)
            if chosen is not None:
                folder = chosen
                state['team_folder'] = chosen
                teamsync.save_state(state)
            continue
        if action == 'pull':
            try:
                result = teamsync.pull(folder)
            except (IOError, OSError) as error:
                toast.error('Could not pull the team settings', str(error))
            else:
                level, message, detail = teamsync.result_toast(result)
                if result.get('needs_reload'):
                    ribbon.reload()
                    detail = detail.replace('Reload pyNavis to apply them.', 'pyNavis reloaded to apply them.')
                toast.show(level, message, detail)
        elif action == 'push':
            if forms.confirm('Write this computer\'s templates, presets, libraries, rules, project settings, '
                             'shortcuts and extension folders to %s? Team files it replaces are backed up '
                             'in playground-team\\.backup.' % folder, title='Team Sync'):
                try:
                    result = teamsync.push(folder)
                except (IOError, OSError) as error:
                    toast.error('Could not push to the team folder', str(error))
                else:
                    toast.success('Pushed to the team folder',
                                  '%d file%s updated, version %s.' % (result['files'], '' if result['files'] == 1 else 's',
                                                                     result['stamp'].replace('T', ' ')))
        break

Library modules this tool uses

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

  • 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.teamsyncTeam Sync: share Playground settings through a team folder (a UNC share or a synced or cloned folder) laid out as <team folder>\playground-team\:
  • 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/Team_Sync.pushbutton/bundle.yaml View on GitHub
title: Team\nSync
tooltip: Pulls the team's templates, presets, rules, shortcuts and project settings from the team folder, or pushes yours to it.