Model > Find
Export Sets
Writes the sets you choose to a Playground XML file: search sets as conditions, selection sets as item references that survive into other files.
Status
Untested Never executed inside Navisworks. Passed the headless checks only.
Related asks to confirm
No quote is on record yet. These threads look related, but a person still has to open and read them.
- https://forums.autodesk.com/t5/navisworks-forum/search-sets-search-in-import-export-transfer-to-other-projects/td-p/12256463
- https://forums.autodesk.com/t5/navisworks-forum/selection-set-xml-export-and-import-navisworks-manage-2009-and/td-p/2686191
Installs with
Export Sets 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/Find.panel/Set_Exchange.stack/Export_Sets.pushbutton/bundle.yamlModel.tab/Find.panel/Set_Exchange.stack/Export_Sets.pushbutton/icon.dark.pngModel.tab/Find.panel/Set_Exchange.stack/Export_Sets.pushbutton/icon.pngModel.tab/Find.panel/Set_Exchange.stack/Export_Sets.pushbutton/icon.small.dark.pngModel.tab/Find.panel/Set_Exchange.stack/Export_Sets.pushbutton/icon.small.pngModel.tab/Find.panel/Set_Exchange.stack/Export_Sets.pushbutton/script.py
Install
- Only this tool. In Navisworks, click pyNavis > Playground, search for Export Sets, 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. Export Sets 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/Set_Exchange.stack/Export_Sets.pushbutton/script.py View on GitHub# -*- coding: utf-8 -*-
"""Writes chosen sets to a Playground XML file: search sets as conditions, static sets as item references."""
import os
from pynavis import forms, toast
from pynavis._api import Application
from namo import find_sets, naming, paths, progress, setexchange, ui
document = Application.ActiveDocument
def default_path():
name = naming.render('{file} - Sets - {date}', naming.standard_values())[0]
name = naming.sanitize(name.strip(' -') or 'Sets', for_file=True)
folder = os.path.dirname(document.FileName or '')
if not folder or not os.path.isdir(folder):
folder = os.path.join(os.path.expanduser('~'), 'Documents')
return os.path.join(folder, name + '.xml')
rows = setexchange.export_rows(document)
if not rows:
toast.info('No sets to export', 'This model has no selection or search sets.')
else:
table = [{'value': i, 'cells': [find_sets.plain_folder(r['folder']), r['name'],
'Search' if r.get('has_search') else 'Static']}
for i, r in enumerate(rows)]
picked = ui.choose('Export sets', table, ['Folder', 'Set', 'Kind'], multiselect=True,
checked=list(range(len(rows))), ok='Next', width=640,
prompt='Tick the sets to export. Folders come along with their sets.')
if picked is not None:
path = forms.save_file('Playground sets (*.xml)|*.xml', default_path(), 'Export sets')
if path is not None:
chosen = [rows[i] for i in picked]
outcome = progress.run('Exporting sets', lambda report: setexchange.collect(
chosen, document, report))
if outcome is not progress.CANCELLED:
meta, tree = outcome
try:
paths.atomic_write_text(path, setexchange.write_xml(meta, tree))
except (IOError, OSError) as error:
toast.error('Could not write the file', str(error))
else:
search, static, count = setexchange.describe_tree(tree)
parts = ['%d search %s' % (search, 'set' if search == 1 else 'sets')]
if static:
parts.append('%d static %s holding %s items' % (
static, 'set' if static == 1 else 'sets', '{:,}'.format(count)))
toast.success('Exported %d %s' % (search + static, 'set' if search + static == 1 else 'sets'),
'%s. %s' % (' and '.join(parts), path))
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.namingName templates: '{test} - {n:000}', '{date:%Y%m%d} {project}', '{{literal braces}}'.namo.pathsWhere Playground keeps its files, and how it writes them safely.namo.progressGlue between pyNavis' cancellable progress window and Playground's progress callbacks.namo.setexchangeSet Exchange: selection sets to and from a portable Playground XML file.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/Set_Exchange.stack/Export_Sets.pushbutton/bundle.yaml View on GitHubtitle: Export Sets
tooltip: Writes the sets you choose to a Playground XML file: search sets as conditions, selection sets as item references that survive into other files.
context: selection-sets