Selection panel

More menu

Show what is in memory, promote it to a selection set, or delete the stored memory files.

On the ribbonMenu, Selection panel
NeedsNothing

What it does#

The pulldown at the end of the panel holds the three things you do to the memory rather than with it.

Show Contents#

Lists the memory in the output window, one row per item with the model it came from and a link that selects it, under a line naming the document it was remembered from and when. Long memories are cut off at 500 rows. An empty memory prints a line telling you to select something and press Remember.

Save as Set#

Promotes the memory to a native Navisworks selection set. It asks for a name, offering "Memory" plus the date and time, and creates the set. Unlike the memory, a selection set is stored inside the document, so this marks the document modified and the set travels with the file. This is how a private memory becomes something the team can see.

Purge#

Deletes the stored memory files for every document, not just this one. It counts the files first and asks for confirmation naming that number, and says so quietly when there is nothing to delete.

Limitations#

  • Save as Set makes a static set of the items as they are now, not a search, so it does not follow the model when new items match.

Source#

The tool's own files, word for word as shipped in Selection.panel/More.pulldown. Every pyNavis tool is an ordinary bundle: copy these into your own extension and change what you like.

bundle.yaml The bundle contract: the keys pyNavis reads for this tool. View on GitHub
title: More
tooltip: Inspect the memory, promote it to a set, or delete stored memory files
layout:
  - Show_Contents
  - Save_as_Set
  - Purge
Purge.pushbutton/script.py Runs on a click. View on GitHub
"""Deletes the stored memory files for every document, not just this one."""

from pynavis import forms, memory, toast

targets = memory.purge_targets()
if not targets:
    toast.info('No memory files to purge')
else:
    question = ('Delete %d stored memory file(s)?\n\n'
                'This clears the memory for every document, not just this one.'
                % len(targets))
    if forms.confirm(question, 'Purge memory files'):
        result = memory.purge()
        toast.show(result.level, result.message, result.detail)
Save_as_Set.pushbutton/script.py Runs on a click. View on GitHub
"""Saves the memory as a Navisworks selection set.

Unlike the memory itself, a set is stored in the document, so this marks the
document as modified.
"""

import datetime

from pynavis import forms, memory, toast

default = 'Memory %s' % datetime.datetime.now().strftime('%Y-%m-%d %H:%M')
name = forms.ask_string('Name for the selection set', default, 'Save memory as set')
if name:
    result = memory.save_as_set(name)
    toast.show(result.level, result.message, result.detail)
Show_Contents.pushbutton/script.py Runs on a click. View on GitHub
"""Lists what is in memory, with a clickable link per item."""

from pynavis import memory, output

state, rows = memory.contents()
if not state['items']:
    output.print_md('**Memory is empty.** Select something and press Remember.')
    note = memory.ignored_note(state)
    if note:
        output.print_md(note)
else:
    output.print_html(memory.contents_html(rows, state))