Model > Find
Quick Find
Finds any element by name, Element ID, category, type, mark or level as you type. Enter selects and zooms, Shift+Enter selects every match. 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/Find.panel/Quick_Find.pushbutton/bundle.yamlModel.tab/Find.panel/Quick_Find.pushbutton/config.pyModel.tab/Find.panel/Quick_Find.pushbutton/icon.dark.pngModel.tab/Find.panel/Quick_Find.pushbutton/icon.pngModel.tab/Find.panel/Quick_Find.pushbutton/icon.small.dark.pngModel.tab/Find.panel/Quick_Find.pushbutton/icon.small.pngModel.tab/Find.panel/Quick_Find.pushbutton/script.py
Install
- Only this tool. In Navisworks, click pyNavis > Playground, search for Quick Find, 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. Quick Find is on the Model tab, Find 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/Find.panel/Quick_Find.pushbutton/script.py View on GitHub# -*- coding: utf-8 -*-
"""Finds any element by name, Element ID, category, type, mark or level as you type."""
from pynavis import script, toast
from pynavis._api import Application
from namo import items, progress, quickfind, session
cfg = script.get_config(quickfind.DEFAULTS)
document = Application.ActiveDocument
def act(index, result):
rows = result['rows']
if result['action'] == 'all' and len(rows) > 2000:
outcome = progress.run('Selecting %s results' % '{:,}'.format(len(rows)),
lambda report: quickfind.resolve(index, rows, document))
if outcome is progress.CANCELLED:
return
found, missing = outcome
else:
found, missing = quickfind.resolve(index, rows, document)
stale = 'Shift+Click Quick Find and rebuild the index if the model changed.'
if not found:
toast.warning('That element is no longer in the model' if len(rows) == 1 else
'Those elements are no longer in the model', stale)
return
shown = index.display(rows[0], result['query'])['name']
if result['action'] == 'select':
items.select(found, zoom=True, doc=document)
toast.success('Selected %s' % shown, index.display(rows[0], result['query'])['detail'] or None)
elif result['action'] == 'add':
document.CurrentSelection.AddRange(items.collection(found))
toast.success('Added %s to the selection' % shown)
else:
items.select(found, doc=document)
message = 'Selected %s %s' % ('{:,}'.format(len(found)), 'result' if len(found) == 1 else 'results')
detail = "Every element matching '%s'." % result['query']
if missing:
toast.warning(message, '%s %d could not be found: %s' % (detail, missing, stale))
else:
toast.success(message, detail)
if document is None or document.Models.Count == 0:
toast.info('Nothing to search', 'Open or append a model first.')
else:
index = quickfind.cached(document, cfg)
if index is None:
built = progress.run('Indexing the model for Quick Find',
lambda report: quickfind.build(document, cfg, report),
'Finding elements')
index = None if built is progress.CANCELLED else built
if index is not None:
if not len(index):
toast.info('Nothing to search', 'The model has no elements with geometry.')
else:
last = session.get('quickfind', 'last_query', '')
result = quickfind.dialog(index, cfg['cap'], last)
if result is not None:
session.set('quickfind', 'last_query', result['query'])
act(index, result)
config.py
The Shift+Click action.
Model.tab/Find.panel/Quick_Find.pushbutton/config.py View on GitHub# -*- coding: utf-8 -*-
"""Options for Quick Find: the fields it searches, how many results it lists, rebuild the index."""
from pynavis import script, toast
from namo import quickfind, ui
cfg = script.get_config(quickfind.DEFAULTS)
values = ui.form('Quick Find', [
{'kind': 'multi', 'key': 'fields', 'label': 'Fields to search',
'options': [(f['label'], f['key']) for f in quickfind.FIELDS], 'default': cfg['fields'],
'hint': 'Name is always searched. Changing the fields rebuilds the index on the next search.'},
{'kind': 'int', 'key': 'cap', 'label': 'Results listed', 'default': cfg['cap'], 'min': 20,
'max': 2000, 'required': True},
{'kind': 'int', 'key': 'budget', 'label': 'Elements indexed at most', 'default': cfg['budget'],
'min': 10000, 'max': 5000000, 'required': True,
'hint': 'Larger models are indexed from the start of the tree up to this many elements.'},
{'kind': 'check', 'key': 'rebuild', 'label': 'Rebuild the index of this model now',
'default': False},
], ok='Save', width=480)
if values is not None:
cfg['fields'] = values['fields'] or ['name']
cfg['cap'] = values['cap']
cfg['budget'] = values['budget']
script.save_config(cfg)
detail = 'Searching %d fields, listing up to %s results.' % (
len(quickfind.field_specs(cfg['fields'])), '{:,}'.format(cfg['cap']))
if values['rebuild']:
quickfind.forget()
detail += ' The index is rebuilt on the next search.'
toast.success('Saved', detail)
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.progressGlue between pyNavis' cancellable progress window and Playground's progress callbacks.namo.quickfindQuick Find: type-ahead search over every element of the model.namo.sessionState that outlives one run, plus the one logger every namo module shares.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/Find.panel/Quick_Find.pushbutton/bundle.yaml View on GitHubtitle: Quick\nFind
tooltip: Finds any element by name, Element ID, category, type, mark or level as you type. Enter selects and zooms, Shift+Enter selects every match. Shift+Click for settings.
shortcut: Ctrl+Alt+F
context: doc