Model > Select

Export Picked

Writes the pick list to Excel or CSV: order, name, category, Element ID, GUID, source file and centre point in model units.

Tab and panelModel > Select
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/Select.panel/Pick_Order_Actions.pulldown/Export_Picked.pushbutton/bundle.yaml
  • Model.tab/Select.panel/Pick_Order_Actions.pulldown/Export_Picked.pushbutton/icon.dark.png
  • Model.tab/Select.panel/Pick_Order_Actions.pulldown/Export_Picked.pushbutton/icon.png
  • Model.tab/Select.panel/Pick_Order_Actions.pulldown/Export_Picked.pushbutton/icon.small.dark.png
  • Model.tab/Select.panel/Pick_Order_Actions.pulldown/Export_Picked.pushbutton/icon.small.png
  • Model.tab/Select.panel/Pick_Order_Actions.pulldown/Export_Picked.pushbutton/script.py

Install

  1. Only this tool. In Navisworks, click pyNavis > Playground, search for Export Picked, 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. Export Picked is on the Model tab, Select 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/Select.panel/Pick_Order_Actions.pulldown/Export_Picked.pushbutton/script.py View on GitHub
# -*- coding: utf-8 -*-
"""Writes the pick list to Excel or CSV with ids, source file and centre point."""
import os

from pynavis import forms, toast

from namo import naming, paths, progress, sel_pickorder, units, xlsx

picks = sel_pickorder.load()


def default_path(document):
    name = naming.render('{file} - Pick order - {date}', naming.standard_values())[0]
    name = naming.sanitize(name.strip(' -') or 'Pick order', 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 + '.xlsx')


def build(found, report):
    rows = []
    for index, item in enumerate(found):
        rows.append(sel_pickorder.export_row(index + 1, sel_pickorder.record_for(item)))
        if index % 50 == 0:
            report(float(index) / max(1, len(found)), 'Reading %d of %d items' % (index, len(found)))
    return rows


if not picks:
    toast.info('No picked items', 'Turn on Pick Order and click items in order first.')
else:
    from pynavis._api import Application
    document = Application.ActiveDocument
    found, missing = sel_pickorder.resolve()
    if not found:
        toast.warning('None of the picked items are in the model',
                      'They may have been removed or re-exported. Clear Picked starts a new list.')
    else:
        path = forms.save_file('Excel workbook (*.xlsx)|*.xlsx|CSV file (*.csv)|*.csv',
                               default_path(document), 'Export picked items')
        if path is not None:
            rows = progress.run('Exporting picked items', lambda report: build(found, report))
            if rows is not progress.CANCELLED:
                headers = sel_pickorder.export_headers(units.doc_unit_symbol(str(document.Units)))
                try:
                    if path.lower().endswith('.csv'):
                        paths.atomic_write_text(path, sel_pickorder.csv_text(headers, rows), 'utf-8-sig')
                    else:
                        xlsx.write_simple(path, [{'name': 'Pick order', 'headers': headers,
                                                  'rows': rows}], title='Pick order')
                except (IOError, OSError) as error:
                    toast.error('Could not write the file', 'Close it in Excel, then try again. %s' % error)
                else:
                    detail = path
                    if missing:
                        detail = '%s (%d picked items are no longer in the model)' % (path, missing)
                    toast.success('Exported %d picked %s' % (len(rows), 'item' if len(rows) == 1 else 'items'),
                                  detail)

Library modules this tool uses

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

  • 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.sel_pickorderPick Order: an ordered list of items the user clicks, and what to do with it.
  • namo.unitsUnits: document lengths, conversions, and quantities as people and Revit write them.
  • namo.xlsxStyled Excel (.xlsx) writer: fills, number formats, widths, frozen headers, autofilter, merged title rows, hyperlinks and embedded images. No Excel needed.

bundle.yaml

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

Model.tab/Select.panel/Pick_Order_Actions.pulldown/Export_Picked.pushbutton/bundle.yaml View on GitHub
title: Export Picked
tooltip: Writes the pick list to Excel or CSV: order, name, category, Element ID, GUID, source file and centre point in model units.
context: doc