Dev > Automate

Play Macro

Runs a saved macro, one command after another. Dialogs inside its commands still ask you; click again to stop a playing macro.

Tab and panelDev > Automate
KindButton

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

It needs these Navisworks event hooks, so installing it also copies the shared hooks folder:

  • after-command

Files

Paths are relative to the Playground.extension folder.

  • Dev.tab/Automate.panel/Macros.pulldown/Play_Macro.pushbutton/bundle.yaml
  • Dev.tab/Automate.panel/Macros.pulldown/Play_Macro.pushbutton/icon.dark.png
  • Dev.tab/Automate.panel/Macros.pulldown/Play_Macro.pushbutton/icon.png
  • Dev.tab/Automate.panel/Macros.pulldown/Play_Macro.pushbutton/icon.small.dark.png
  • Dev.tab/Automate.panel/Macros.pulldown/Play_Macro.pushbutton/icon.small.png
  • Dev.tab/Automate.panel/Macros.pulldown/Play_Macro.pushbutton/script.py

Install

  1. Only this tool. In Navisworks, click pyNavis > Playground, search for Play Macro, 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. Play Macro is on the Dev tab, Automate 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.

Dev.tab/Automate.panel/Macros.pulldown/Play_Macro.pushbutton/script.py View on GitHub
# -*- coding: utf-8 -*-
"""Plays a saved macro, or stops the one that is playing."""
from pynavis import forms, toast

from namo import macros

player = macros.playing()
if player is not None:
    if forms.confirm('Macro %s is playing (step %d of %d). Stop it?'
                     % (player.name, min(player.index + 1, len(player.steps)), len(player.steps)),
                     title='Play Macro'):
        player.stop()
else:
    names = macros.names()
    if not names:
        toast.info('There are no macros yet', 'Click Record Macro, run some commands, then click Stop Recording.')
    else:
        choices = [('%s  (%s)' % (name, macros.describe(macros.load(name) or {})), name) for name in names]
        name = forms.select_from_list(choices, title='Play Macro',
                                      prompt='Pick the macro to play. Dialogs inside its commands still ask you.')
        if name is not None:
            config = macros.load(name)
            if config is None or not config['steps']:
                toast.info('Macro %s has no steps' % name, 'Add steps in Manage Macros.')
            else:
                toast.info('Playing macro %s' % name, '%s. Click Play Macro again to stop it.' % macros.describe(config))
                macros.play(name, config)

Library modules this tool uses

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

  • namo.macrosMacros: record pyNavis commands, play them back in order, manage them.

bundle.yaml

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

Dev.tab/Automate.panel/Macros.pulldown/Play_Macro.pushbutton/bundle.yaml View on GitHub
title: Play Macro
tooltip: Runs a saved macro, one command after another. Dialogs inside its commands still ask you; click again to stop a playing macro.