Model > Find

Search Set Wizard

Builds a search set step by step: where to search, conditions picked from the model's own properties and values, a live count, then name and folder.

Tab and panelModel > Find
KindButton
Live whenA model is open

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/Search_Set_Wizard.pushbutton/bundle.yaml
  • Model.tab/Find.panel/Search_Set_Wizard.pushbutton/icon.dark.png
  • Model.tab/Find.panel/Search_Set_Wizard.pushbutton/icon.png
  • Model.tab/Find.panel/Search_Set_Wizard.pushbutton/icon.small.dark.png
  • Model.tab/Find.panel/Search_Set_Wizard.pushbutton/icon.small.png
  • Model.tab/Find.panel/Search_Set_Wizard.pushbutton/script.py

Install

  1. Only this tool. In Navisworks, click pyNavis > Playground, search for Search Set Wizard, 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. Search Set Wizard 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.

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.

Model.tab/Find.panel/Search_Set_Wizard.pushbutton/script.py View on GitHub
# -*- coding: utf-8 -*-
"""Builds a search set step by step: scope, conditions from the model's own values, count, save."""
from pynavis import script, toast
from pynavis._api import Application

from namo import find_sets, items, progress, setwizard

cfg = script.get_config({'model': None})
document = Application.ActiveDocument

if document is None or document.Models.Count == 0:
    toast.info('Nothing to search', 'Open or append a model first.')
else:
    sample = progress.run('Reading the model for the wizard',
                          lambda report: setwizard.build_sample(document, report=report),
                          'Sampling elements')
    if sample is not progress.CANCELLED:
        source = setwizard.LiveSource(sample, document)
        answer = setwizard.dialog(cfg.get('model') or setwizard.new_model(), source,
                                  [m['name'] for m in items.models(document)],
                                  setwizard.folder_paths(document))
        if answer is not None:
            model, counted = answer
            script.save_config({'model': model})
            kinds = sample.kinds()
            try:
                names = setwizard.create(model, kinds, document)
            except ValueError as error:
                toast.error('Could not create the search set', str(error))
            else:
                key = setwizard.query_key(setwizard.queries(model, kinds), model)
                if model['select_now'] or counted is None or counted['key'] != key:
                    found = setwizard.matches(model, kinds, document)
                    total = found.Count
                    if model['select_now']:
                        items.select(found, doc=document)
                else:
                    total = counted['union']
                where = " in '%s'" % find_sets.plain_folder(model['folder']) if model['folder'] else ''
                count_text = '%s %s' % ('{:,}'.format(total), 'item' if total == 1 else 'items')
                if len(names) == 1:
                    message = "Created search set '%s' (%s)" % (names[0], count_text)
                else:
                    message = 'Created %d search sets (%s in all)' % (len(names), count_text)
                detail = 'Saved%s.%s' % (where, ' The matches are selected.' if model['select_now'] else '')
                if total:
                    toast.success(message, detail)
                else:
                    toast.warning(message, 'It finds nothing yet. Check the values, or the Search In scope.')

Library modules this tool uses

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

  • namo.find_setsThe saved-sets tree, shared by the Find tools: paths, lookups and creating sets.
  • namo.itemsModel items: walking, collecting, identifying, measuring and showing them.
  • namo.progressGlue between pyNavis' cancellable progress window and Playground's progress callbacks.
  • namo.setwizardSearch Set Wizard: a guided builder for Navisworks search sets.

bundle.yaml

The bundle contract: the keys pyNavis reads for this tool.

Model.tab/Find.panel/Search_Set_Wizard.pushbutton/bundle.yaml View on GitHub
title: Search Set\nWizard
tooltip: Builds a search set step by step: where to search, conditions picked from the model's own properties and values, a live count, then name and folder.
context: doc