Model > Look
Background
Steps the view background through White, Light gradient, Dark gradient, Black and Horizon. Shift+Click picks one from the list or a custom color.
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: 'Background'; result not checked by a person.
The public ask
No public source is on record for this tool.
Installs with
Background sits in a stack, so installing it also installs:
Events it listens to
None. It runs only when you click it.
Files
Paths are relative to the Playground.extension folder.
Model.tab/Look.panel/View_Tools.stack/Background.pushbutton/bundle.yamlModel.tab/Look.panel/View_Tools.stack/Background.pushbutton/config.pyModel.tab/Look.panel/View_Tools.stack/Background.pushbutton/icon.dark.pngModel.tab/Look.panel/View_Tools.stack/Background.pushbutton/icon.pngModel.tab/Look.panel/View_Tools.stack/Background.pushbutton/icon.small.dark.pngModel.tab/Look.panel/View_Tools.stack/Background.pushbutton/icon.small.pngModel.tab/Look.panel/View_Tools.stack/Background.pushbutton/script.py
Install
- Only this tool. In Navisworks, click pyNavis > Playground, search for Background, 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. Background is on the Model tab, Look 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.
Model.tab/Look.panel/View_Tools.stack/Background.pushbutton/script.py View on GitHub"""Steps the view background to the next preset: White, Light gradient, Dark gradient, Black, Horizon."""
from namo import look_tools
from pynavis import doc as nwdoc
from pynavis import toast
def run():
document = nwdoc.get_doc()
index = look_tools.next_background(look_tools.current_background_index(document))
spec = look_tools.BACKGROUNDS[index]
try:
look_tools.set_background(spec, document)
except Exception as error:
toast.error('Could not change the background', str(error))
return
look_tools.remember_background(index)
following = look_tools.BACKGROUNDS[look_tools.next_background(index)]['name']
toast.success('Background: %s' % spec['name'], 'Click again for %s. Shift+Click to pick one.' % following)
run()
config.py
The Shift+Click action.
Model.tab/Look.panel/View_Tools.stack/Background.pushbutton/config.py View on GitHub"""Picks a background preset, or a custom color or gradient, from a list."""
from namo import look_tools, ui
from pynavis import doc as nwdoc
from pynavis import script, toast
DEFAULTS = {'choice': look_tools.BACKGROUNDS[0]['name'], 'top': 'FFFFFF', 'bottom': 'C9D1DB'}
cfg = script.get_config(DEFAULTS)
values = ui.form('Background', look_tools.background_fields(cfg), ok='Apply')
if values is not None: # None means cancelled: say nothing
spec = look_tools.background_from_form(values)
if spec is None:
toast.error('That background cannot be shown', 'Pick a preset, or a valid color like 4E79A7.')
else:
cfg.update(values)
script.save_config(cfg)
try:
look_tools.set_background(spec, nwdoc.get_doc())
except Exception as error:
toast.error('Could not change the background', str(error))
else:
look_tools.remember_background(look_tools.match_background(spec))
toast.success('Background: %s' % spec['name'])
Library modules this tool uses
From the shared namo library, which installs with every tool. Each name opens the module on GitHub.
namo.look_toolsThe small Look tools: Match Appearance, Reset All Overrides and Background.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.
Model.tab/Look.panel/View_Tools.stack/Background.pushbutton/bundle.yaml View on GitHubtitle: Background
tooltip: Steps the view background through White, Light gradient, Dark gradient, Black and Horizon. Shift+Click picks one from the list or a custom color.
context: doc