Viewpoints panel

Paste State

Put back a kind of state copied earlier with Copy State.

On the ribbonStacked button, Viewpoints panel
NeedsSomething copied for this document

What it does#

Offers only the kinds actually copied for this document and restores the one you pick. With nothing copied yet it says so instead of showing an empty picker.

Source#

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

script.py Runs on a click. View on GitHub
"""Pastes a kind of view state copied earlier with Copy State.

Only the kinds actually copied for this document are offered; with nothing
copied yet the tool says so instead of showing an empty picker.
"""

from pynavis import forms, toast, viewstate

kinds = viewstate.available_kinds()

if not kinds:
    forms.alert('No copied state for this document. Use "Copy State" first.',
                title='Paste State')
else:
    # prompt=None gives the chromeless quick switch, same as Copy State.
    label = forms.ask_options(
        None,
        [viewstate.label_for(kind) for kind in kinds],
        title='Paste State',
    )
    if label is not None:                      # None means cancelled: say nothing
        result = viewstate.paste_state(viewstate.kind_for(label))
        toast.show(result.level, result.message, result.detail)
bundle.yaml The bundle contract: the keys pyNavis reads for this tool. View on GitHub
title: Paste State
tooltip: Paste the section planes, hidden items, or appearance overrides copied for this document
context: doc