Project > Quality
Health Check
Scores every appended model from 0 to 100 on units, distance from the origin, far-away objects, element IDs, duplicate appends, transforms and file age, with an HTML and Excel report. Shift+Click to set the thresholds and report formats.
Status
Launched Ran inside Navisworks at least once with no error logged; nobody checked the result yet.
Ran headless under pynavis run against a sample model; no selection: ran to the end (wrote output); result not checked by a person.
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.
Project.tab/Quality.panel/Model_Health_Check.pushbutton/bundle.yamlProject.tab/Quality.panel/Model_Health_Check.pushbutton/config.pyProject.tab/Quality.panel/Model_Health_Check.pushbutton/icon.dark.pngProject.tab/Quality.panel/Model_Health_Check.pushbutton/icon.pngProject.tab/Quality.panel/Model_Health_Check.pushbutton/icon.small.dark.pngProject.tab/Quality.panel/Model_Health_Check.pushbutton/icon.small.pngProject.tab/Quality.panel/Model_Health_Check.pushbutton/script.py
Install
- Only this tool. In Navisworks, click pyNavis > Playground, search for Health Check, 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. Health Check is on the Project tab, Quality 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.
Project.tab/Quality.panel/Model_Health_Check.pushbutton/script.py View on GitHub# -*- coding: utf-8 -*-
"""Scores every appended model for units, origin distance, stray objects, element IDs, duplicates, transforms and file age."""
import os
from pynavis import doc as nwdoc
from pynavis import output, script, toast
from namo import health, mdl_output, progress, reports, rep_health_check, ui
def report_config(values, document):
"""The report config from this button's settings: the document's folder when it
is saved and no folder was chosen."""
config = rep_health_check.default_config()
config.update(health.settings(values))
if not config.get('folder'):
filename = nwdoc.get_filename(document) or ''
if filename and os.path.isdir(os.path.dirname(filename)):
config['folder'] = os.path.dirname(filename)
return config
def link_for(model, outlier_items):
found = outlier_items.get(model['index']) or []
outliers = model.get('outliers') or []
def link(i):
if i < len(found) and i < len(outliers):
return output.element_link(found[i], outliers[i].get('name') or 'Object')
return None
return link
def run():
document = nwdoc.get_doc()
values = health.settings(script.get_config(health.DEFAULTS))
config = report_config(values, document)
result = progress.run('Health check', lambda report: reports.run(
'health_check', config, doc=document, interactive=True, progress=report))
if result is progress.CANCELLED or result.get('cancelled'):
return
models = result.get('models') or []
if not models:
toast.show(result['level'], result['message'], result['detail'] or None)
return
outlier_items = result.get('outlier_items') or {}
output.set_title('Model health check')
output.print_html(mdl_output.heading('Model health check', 1) + health.overview_html(models))
ordered = sorted(models, key=lambda m: (m['score'], m['index']))
for model in ordered:
output.print_html(health.card_html(model, link_for(model, outlier_items)))
paths = result.get('paths') or []
for path in paths:
output.print_html(mdl_output.path_line('Saved:', path))
if result['level'] == 'error':
toast.error(result['message'], result['detail'] or None)
return
level, message, detail = health.summary(models)
toast.show(level, message, detail)
html = [p for p in paths if p.lower().endswith('.html')]
if values['open_report'] and html:
ui.open_path(html[0])
run()
config.py
The Shift+Click action.
Project.tab/Quality.panel/Model_Health_Check.pushbutton/config.py View on GitHub# -*- coding: utf-8 -*-
"""Settings for Model Health Check: thresholds, report formats and where the reports go."""
from pynavis import script, toast
from namo import health, ui
def run():
values = health.settings(script.get_config(health.DEFAULTS))
fields = [
{'kind': 'label', 'text': 'Distance of a model centre from 0,0,0', 'muted': True},
{'kind': 'number', 'key': 'warn_km', 'label': 'Warn beyond', 'default': values['warn_km'],
'min': 0.001, 'suffix': 'km', 'required': True},
{'kind': 'number', 'key': 'fail_km', 'label': 'Fail beyond', 'default': values['fail_km'],
'min': 0.001, 'suffix': 'km', 'required': True},
{'kind': 'number', 'key': 'outlier_factor', 'label': 'Far-away object', 'default': values['outlier_factor'],
'min': 2, 'max': 1000, 'suffix': 'x typical distance', 'required': True,
'hint': 'An object farther than this many times the typical object distance from the model centre.'},
{'kind': 'int', 'key': 'age_days', 'label': 'Old file after', 'default': values['age_days'],
'min': 1, 'max': 3650, 'suffix': 'days', 'required': True},
{'kind': 'int', 'key': 'item_budget', 'label': 'Items read per model', 'default': values['item_budget'],
'min': 10000, 'max': 20000000, 'required': True,
'hint': 'Counting stops here on very large models, and the report says so.'},
{'kind': 'separator'},
{'kind': 'multi', 'key': 'formats', 'label': 'Reports',
'options': [('HTML report', 'html'), ('Excel workbook', 'xlsx')], 'default': values['formats']},
{'kind': 'folder', 'key': 'folder', 'label': 'Save reports in', 'default': values['folder'],
'hint': 'Blank: the document\'s folder, or Playground\'s reports folder for an unsaved document.'},
{'kind': 'check', 'key': 'open_report', 'label': 'Open the HTML report when done',
'default': values['open_report']},
]
def check(answer):
if answer.get('warn_km') is not None and answer.get('fail_km') is not None \
and answer['fail_km'] < answer['warn_km']:
return {'fail_km': 'Fail must be at least the warning distance.'}
return None
answer = ui.form('Health check settings', fields, validate=check)
if answer is None:
return
saved = health.settings(answer)
script.save_config(saved)
toast.success('Health check settings saved',
'Warn at %s km, fail at %s km.' % (health.num_text(saved['warn_km']), health.num_text(saved['fail_km'])))
run()
Library modules this tool uses
From the shared namo library, which installs with every tool. Each name opens the module on GitHub.
namo.healthModel Health Check: a scorecard per appended model.namo.mdl_outputOutput-window HTML for the Models, Quality and Publish tools (pure string building).namo.progressGlue between pyNavis' cancellable progress window and Playground's progress callbacks.namo.rep_health_checkModel Health Check: a scorecard per appended model, as an HTML report and a workbook.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.
Project.tab/Quality.panel/Model_Health_Check.pushbutton/bundle.yaml View on GitHubtitle: Health\nCheck
tooltip: Scores every appended model from 0 to 100 on units, distance from the origin, far-away objects, element IDs, duplicate appends, transforms and file age, with an HTML and Excel report. Shift+Click to set the thresholds and report formats.
context: doc