Model > Look
Trade Ghost
Keeps the trades you choose, or the selection, solid and fades every other model to a transparent grey. Click again to change the focus or clear the ghost. Shift+Click for settings.
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.
Model.tab/Look.panel/Trade_Ghost.pushbutton/bundle.yamlModel.tab/Look.panel/Trade_Ghost.pushbutton/config.pyModel.tab/Look.panel/Trade_Ghost.pushbutton/icon.dark.pngModel.tab/Look.panel/Trade_Ghost.pushbutton/icon.pngModel.tab/Look.panel/Trade_Ghost.pushbutton/icon.small.dark.pngModel.tab/Look.panel/Trade_Ghost.pushbutton/icon.small.pngModel.tab/Look.panel/Trade_Ghost.pushbutton/script.py
Install
- Only this tool. In Navisworks, click pyNavis > Playground, search for Trade Ghost, 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. Trade Ghost 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/Trade_Ghost.pushbutton/script.py View on GitHub"""Keeps the chosen trades or the selection solid and ghosts every other model; click again to change or clear."""
from namo import items, look_ghost, paint, ui
from pynavis import doc as nwdoc
from pynavis import forms, script, toast
TITLE = 'Trade Ghost'
def choose_focus(document, cfg):
"""The focus values ticked in the chooser, or None on cancel."""
groups, _models = look_ghost.model_groups(document)
selected = items.selected(document)
rows = look_ghost.chooser_rows([(t, [m['name'] for m in ms]) for t, ms in groups], len(selected))
remembered = [t for t in cfg['trades'] if t in [g[0] for g in groups]]
picked = ui.choose(TITLE, rows, ['Focus', 'Size', 'Models'], multiselect=True, checked=remembered,
ok='Ghost the rest',
prompt='Tick what stays solid. Everything else fades to %d%% transparent.'
% cfg['transparency'])
return picked, groups
def ghost(document, cfg, record):
picked, groups = choose_focus(document, cfg)
if picked is None:
return
keep = look_ghost.focus_items(picked, groups, document)
if not keep:
toast.info('Nothing to keep solid', 'Tick a trade, or select something and tick Current selection.')
return
previous = []
if record is not None:
previous, _missing = items.resolve(record['entries'], document)
cfg['trades'] = [p for p in picked if p != look_ghost.SELECTION]
script.save_config(cfg)
others = look_ghost.ghost(keep, cfg, previous, document)
label = look_ghost.focus_label(picked)
if not others:
look_ghost.save_record(None, document)
toast.info('Nothing left to ghost', '%s is the whole model.' % label)
return
look_ghost.save_record(look_ghost.make_record(items.entries(others, document), label, cfg), document)
toast.success('Ghosted everything but %s' % label,
'%d%% transparent%s. Click Trade Ghost again to change or clear it.'
% (cfg['transparency'], ' and grey' if cfg['grey'] else ''))
def clear(document, record):
count, missing = look_ghost.clear(record, document)
look_ghost.save_record(None, document)
if missing and not count:
if forms.confirm('The ghosted items could not be found again. Reset every color and '
'transparency in the model instead?', title=TITLE):
paint.reset(None, document, 'Clear ghost')
toast.success('Ghost cleared', 'Every color and transparency is back to the model.')
return
toast.success('Ghost cleared', 'Everything outside %s is back to its own colors.' % record.get('focus', 'the focus'))
def run():
document = nwdoc.get_doc()
if document.Models.Count == 0:
toast.info('No model open', 'Open or append models, then run Trade Ghost again.')
return
cfg = look_ghost.normalize_config(script.get_config(look_ghost.DEFAULTS))
record = look_ghost.load_record(document)
if record is None:
ghost(document, cfg, None)
return
action = forms.ask_options(None, [look_ghost.CHANGE, look_ghost.CLEAR], title=TITLE)
if action == look_ghost.CHANGE:
ghost(document, cfg, record)
elif action == look_ghost.CLEAR:
clear(document, record)
run()
config.py
The Shift+Click action.
Model.tab/Look.panel/Trade_Ghost.pushbutton/config.py View on GitHub"""Sets how transparent Trade Ghost makes everything outside the focus, and whether it turns grey."""
from namo import look_ghost, ui
from pynavis import script, toast
cfg = look_ghost.normalize_config(script.get_config(look_ghost.DEFAULTS))
values = ui.form('Trade Ghost settings', look_ghost.config_fields(cfg), ok='Save')
if values is not None: # None means cancelled: say nothing
cfg.update(values)
cfg = look_ghost.normalize_config(cfg)
script.save_config(cfg)
toast.success('Saved', 'Trade Ghost fades the rest to %d%% transparent%s.'
% (cfg['transparency'], ' and grey' if cfg['grey'] else ''))
Library modules this tool uses
From the shared namo library, which installs with every tool. Each name opens the module on GitHub.
namo.itemsModel items: walking, collecting, identifying, measuring and showing them.namo.look_ghostTrade Ghost: one or more trades stay solid, every other model fades.namo.paintColouring model items: permanent colour/transparency overrides, ghosting, reset.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/Trade_Ghost.pushbutton/bundle.yaml View on GitHubtitle: Trade\nGhost
tooltip: Keeps the trades you choose, or the selection, solid and fades every other model to a transparent grey. Click again to change the focus or clear the ghost. Shift+Click for settings.
context: doc