Viewpoints panel

Viewpoint Tracker

A dock panel that always says which saved view you are looking through, and whether you are still on it.

On the ribbonDock panel, Viewpoints panel
NeedsNothing

What it does#

Two lines, live. The top line reads "Active viewpoint" while the camera still sits where the saved view put it and "Last viewpoint" once you have walked off. The bottom line is the view's name, sized to fit the panel. Click the name to go back.

How to use it#

  1. Click Viewpoint Tracker on the ribbon to show the panel. Dock it wherever suits; the button follows the panel's visibility.
  2. Recall views as usual. The panel updates within a quarter of a second of the camera settling.

Limitations#

  • Before any saved view has been current it shows "No viewpoint selected".
  • View > Windows lists the panel by its slot name, "pyNavis Panel N", not by its title.

Other uses#

  • Presenting: the audience can see which view is on screen without you saying so.
  • Tracker Window in the panel flyout is the same two lines as a floating always-on-top window, for when the dock panel is in the way.

Source#

The tool's own files, word for word as shipped in Viewpoints.panel/Viewpoint_Tracker.dockpane. 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
# -*- coding: utf-8 -*-
"""Shows which saved viewpoint the camera is looking through, live.

Two lines: whether the camera is still on the view or has walked off it, and
the view's name. Clicking the name goes back to that view.

All of the behaviour is in lib/vptrackerlive.py, which the floating Tracker
Window shares, so the panel and the window can never disagree.

Reload re-runs this script against fresh TextBlocks: PaneRegistry.Configure is
"Boot and Reload: re-read the claims and re-content any open pane", and it
re-contents through PaneContentBuilder.Build. The previous run's timer and
subscriptions are still live at that point and would go on painting into
TextBlocks that are no longer on screen, so the last detach is kept in the
session holder (which outlives a run) and called before a new one is wired.
"""

import vptrackerlive

from pynavis import script

pane = __pane__

held = vptrackerlive.session()

previous = getattr(held, 'pane_detach', None)
if previous is not None:
    previous()              # self-guarded: detach() wraps its own body

held.pane_detach = vptrackerlive.attach(
    pane.Find('Status'), pane.Find('ViewName'), script.get_logger())['detach']
pane.xaml The dock panel's content. View on GitHub
<Grid xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      Margin="12">
  <Grid.RowDefinitions>
    <RowDefinition Height="Auto"/>
    <RowDefinition Height="*"/>
  </Grid.RowDefinitions>

  <TextBlock x:Name="Status" Grid.Row="0" Text=""
             FontSize="11" TextAlignment="Center" Opacity="0.75"/>

  <!-- The Viewbox does what the C# did with a binary search over MeasureString:
       shrink a long name to fit and grow a short one, capped so a three letter
       name does not fill the panel. No colours are set anywhere here, so the
       panel follows the Navisworks theme instead of the hardcoded white and
       blue the original used. -->
  <Viewbox Grid.Row="1" Margin="0,6,0,0" MaxHeight="72"
           HorizontalAlignment="Center" VerticalAlignment="Center">
    <TextBlock x:Name="ViewName" Text="No viewpoint selected"
               FontSize="28" FontWeight="SemiBold" TextAlignment="Center"
               Background="Transparent" Cursor="Hand"/>
  </Viewbox>
</Grid>
bundle.yaml The bundle contract: the keys pyNavis reads for this tool. View on GitHub
title: Viewpoint Tracker
tooltip: A panel showing which saved viewpoint you are looking through, and whether the camera is still on it. Click the name to go back to that view.
keytip: VT