Coordinate > Issues

KPI Export

Exports issues, comments, clash results, clash tests and clash history as CSV and JSON tables for Power BI, with a README describing every column. Shift+Click to set a fixed folder for scheduled refreshes.

Tab and panelCoordinate > Issues
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.

  • Coordinate.tab/Issues.panel/KPI_Export.pushbutton/bundle.yaml
  • Coordinate.tab/Issues.panel/KPI_Export.pushbutton/config.py
  • Coordinate.tab/Issues.panel/KPI_Export.pushbutton/icon.dark.png
  • Coordinate.tab/Issues.panel/KPI_Export.pushbutton/icon.png
  • Coordinate.tab/Issues.panel/KPI_Export.pushbutton/icon.small.dark.png
  • Coordinate.tab/Issues.panel/KPI_Export.pushbutton/icon.small.png
  • Coordinate.tab/Issues.panel/KPI_Export.pushbutton/script.py

Install

  1. Only this tool. In Navisworks, click pyNavis > Playground, search for KPI Export, 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. KPI Export is on the Coordinate tab, Issues 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.

Coordinate.tab/Issues.panel/KPI_Export.pushbutton/script.py View on GitHub
# -*- coding: utf-8 -*-
"""Exports the issue and clash KPI tables (CSV and JSON) for Power BI into a folder."""
import os

from pynavis import forms, script, toast

from namo import issuestore, progress, rep_kpi_export, reports, ui

DEFAULTS = dict(rep_kpi_export.default_config(), fixed_folder='', last_folder='')


def run():
    me = script.bind()
    values = me.get_config(dict(DEFAULTS))
    doc = issuestore.active_doc()
    store = issuestore.for_doc(doc) if doc is not None else None
    if store is None or not store.saved:
        toast.info('Save the model first', 'The export is keyed by the model file; save it, then export.')
        return
    folder = str(values.get('fixed_folder') or '').strip()
    if not folder:
        start = values.get('last_folder') or os.path.dirname(store.doc_path)
        folder = forms.pick_folder('Folder for the KPI tables', start if os.path.isdir(start) else None)
        if folder is None:
            return
        values['last_folder'] = folder
        me.save_config(values)
    config = dict(values)
    config['folder'] = folder
    result = progress.run('KPI export', lambda report: reports.run(
        'kpi_export', config, doc=doc, interactive=True, progress=report))
    if result is progress.CANCELLED or result.get('cancelled'):
        return
    toast.show(result['level'], result['message'], result['detail'])
    if result['level'] in ('success', 'warning') and result['paths']:
        try:
            ui.show_in_explorer(result['paths'][0])
        except Exception:
            pass


run()

config.py

The Shift+Click action.

Coordinate.tab/Issues.panel/KPI_Export.pushbutton/config.py View on GitHub
# -*- coding: utf-8 -*-
"""Options for KPI Export: a fixed folder for scheduled refreshes, the tables and formats."""
from pynavis import script, toast

from namo import rep_kpi_export, ui

DEFAULTS = dict(rep_kpi_export.default_config(), fixed_folder='', last_folder='')

values = script.get_config(dict(DEFAULTS))
fields = [
    {'kind': 'folder', 'key': 'fixed_folder', 'label': 'Always export to',
     'default': values.get('fixed_folder') or '',
     'hint': 'Blank: ask for a folder each time. Point Power BI at this folder for scheduled refresh.'},
    {'kind': 'text', 'key': 'name_template', 'label': 'Subfolder',
     'default': values.get('name_template') or '',
     'hint': '{file} KPI keeps one subfolder per model; blank writes straight into the folder.'},
    {'kind': 'multi', 'key': 'tables', 'label': 'Tables',
     'options': [(name.replace('_', ' ').capitalize(), name) for name in rep_kpi_export.TABLE_NAMES],
     'default': values.get('tables') or list(rep_kpi_export.TABLE_NAMES)},
    {'kind': 'multi', 'key': 'formats', 'label': 'Formats',
     'options': [('CSV (UTF-8 with BOM)', 'csv'), ('JSON', 'json')],
     'default': values.get('formats') or ['csv', 'json']},
    {'kind': 'int', 'key': 'max_clash_rows', 'label': 'Clash results, at most', 'min': 1000,
     'max': 5000000, 'default': values.get('max_clash_rows')},
]


def check(answers):
    if not answers['tables']:
        return {'tables': 'Tick at least one table.'}
    if not answers['formats']:
        return {'formats': 'Tick at least one format.'}
    return None


answers = ui.form('KPI Export options', fields, ok='Save', width=540, validate=check)
if answers is not None:
    values.update(answers)
    script.save_config(values)
    where = values['fixed_folder'] or 'a folder you choose each time'
    toast.success('Saved KPI Export options', 'Tables go to %s.' % where)

Library modules this tool uses

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

  • namo.issuestoreWhere Playground issues live: one record per issue, per model file, in the data mode namo.config chooses, plus the session events every issue view listens to.
  • namo.progressGlue between pyNavis' cancellable progress window and Playground's progress callbacks.
  • namo.rep_kpi_exportKPI Export: flat tables for Power BI (or any BI tool) from the issue register and Clash Detective, written as CSV (UTF-8 with BOM, which Excel and Power BI read without asking) and JSON into one folder, with a README.txt describing every column.
  • namo.reportsThe registry of automation-ready reports, and the helpers every report 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.

Coordinate.tab/Issues.panel/KPI_Export.pushbutton/bundle.yaml View on GitHub
title: KPI\nExport
tooltip: Exports issues, comments, clash results, clash tests and clash history as CSV and JSON tables for Power BI, with a README describing every column. Shift+Click to set a fixed folder for scheduled refreshes.
context: doc