Project > Models
Folder Watch
Watches the files of the appended models and, when one changes on disk, offers to refresh it with a small notice that never takes focus. Shift+Click to choose the folders, how often to check and whether to start with Navisworks.
Status
Launched Ran inside Navisworks at least once with no error logged; nobody checked the result yet.
Ran headless under pynavis run against a sample model; no selection: ran to the end: 'Folder Watch is on'; result not checked by a person.
The public ask
No public source is on record for this tool.
Events it listens to
It needs these Navisworks event hooks, so installing it also copies the shared hooks folder:
app-closingdoc-opened
Files
Paths are relative to the Playground.extension folder.
Project.tab/Models.panel/Folder_Watch.toggle/bundle.yamlProject.tab/Models.panel/Folder_Watch.toggle/config.pyProject.tab/Models.panel/Folder_Watch.toggle/icon.dark.pngProject.tab/Models.panel/Folder_Watch.toggle/icon.off.dark.pngProject.tab/Models.panel/Folder_Watch.toggle/icon.off.pngProject.tab/Models.panel/Folder_Watch.toggle/icon.on.dark.pngProject.tab/Models.panel/Folder_Watch.toggle/icon.on.pngProject.tab/Models.panel/Folder_Watch.toggle/icon.pngProject.tab/Models.panel/Folder_Watch.toggle/icon.small.dark.pngProject.tab/Models.panel/Folder_Watch.toggle/icon.small.pngProject.tab/Models.panel/Folder_Watch.toggle/script.py
Install
- Only this tool. In Navisworks, click pyNavis > Playground, search for Folder Watch, tick it and click Install.
- The whole extension. Download
Playground.extension.zip, unzip it, put thePlayground.extensionfolder in%APPDATA%\pyNavis\extensions\, and click pyNavis > Reload. Folder Watch is on the Project tab, Models 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.
ReportSource
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.
Project.tab/Models.panel/Folder_Watch.toggle/script.py View on GitHub# -*- coding: utf-8 -*-
"""Starts or stops watching the appended models' files for changes."""
from namo import folderwatch
from pynavis import script, toast
def run():
if folderwatch.is_on():
folderwatch.stop(save=True)
script.set_toggle_state(False)
toast.info('Folder Watch is off')
return
result = folderwatch.start(logger=script.get_logger())
script.set_toggle_state(bool(result['ok']))
toast.show(result['level'], result['message'], result['detail'])
run()
config.py
The Shift+Click action.
Project.tab/Models.panel/Folder_Watch.toggle/config.py View on GitHub# -*- coding: utf-8 -*-
"""Options for Folder Watch: the folders to watch, how often to check, and whether to start with Navisworks."""
import os
from namo import folderwatch, ui
from pynavis import toast
def run():
values = folderwatch.load_config()
fields = [
{'kind': 'textarea', 'key': 'folders', 'label': 'Folders to watch', 'rows': 4,
'default': '\n'.join(values['folders']),
'placeholder': 'One folder per line',
'hint': 'Leave empty to watch the folders the appended models were loaded from.'},
{'kind': 'int', 'key': 'interval', 'label': 'Check every', 'suffix': 's',
'default': values['interval'], 'min': folderwatch.MIN_INTERVAL,
'max': folderwatch.MAX_INTERVAL, 'required': True},
{'kind': 'check', 'key': 'watch_sources', 'default': values['watch_sources'],
'label': 'Also watch the native files (RVT, IFC, DWG) the models were made from'},
{'kind': 'check', 'key': 'remember', 'default': values['remember'],
'label': 'Start watching with Navisworks when it was on at the last close'},
]
answer = ui.form('Folder Watch', fields, ok='Save')
if answer is None:
return
values['folders'] = [line for line in answer['folders'].splitlines() if line.strip()]
values['interval'] = answer['interval']
values['watch_sources'] = answer['watch_sources']
values['remember'] = answer['remember']
missing = [f for f in values['folders'] if not os.path.isdir(f.strip().strip('"'))]
try:
folderwatch.save_config(values)
except (IOError, OSError) as error:
toast.error('Could not save the options', str(error))
return
if folderwatch.is_on():
result = folderwatch.start(values)
toast.success('Folder Watch options saved', result['detail'])
elif missing:
toast.warning('Folder Watch options saved',
'%s not found: %s' % ('Folder' if len(missing) == 1 else 'Folders', ', '.join(missing[:3])))
else:
toast.success('Folder Watch options saved', 'Used the next time you start watching.')
run()
Library modules this tool uses
From the shared namo library, which installs with every tool. Each name opens the module on GitHub.
namo.folderwatchFolder Watch: notices when an appended model's file changes on disk and offers a refresh.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.
Project.tab/Models.panel/Folder_Watch.toggle/bundle.yaml View on GitHubtitle: Folder\nWatch
title_on: Watching
tooltip: Watches the files of the appended models and, when one changes on disk, offers to refresh it with a small notice that never takes focus. Shift+Click to choose the folders, how often to check and whether to start with Navisworks.
tooltip_on: Watching the model files for changes. Click to stop; Shift+Click for the folders and how often to check.