Data panel

Get Coordinates

Click a point in the view and its coordinates land on the clipboard, snapped the way a measurement snaps.

On the ribbonStacked button, Data panel
NeedsAn open document

What it does#

Puts the view into a pick that runs on the native Measure tool, so the pointer snaps to vertices, edges and line ends exactly as a measurement does. The point that reaches the clipboard is the snapped one, written as X, Y, Z at three decimals in model units, which is the shape Go to Coordinates reads back.

How to use it#

  1. Click Get Coordinates.
  2. Click the point. The cursor snaps as you hover.
  3. Paste wherever the point is needed: a report, a survey schedule, an email, or Go to Coordinates.

Limitations#

  • Model units, not a shared coordinate system. If the model is offset from the survey grid, so is the point.
  • Esc, a right-click or picking another tool cancels and copies nothing.

Other uses#

  • Report exactly where a clash is to someone who does not have the model open.

Source#

The tool's own files, word for word as shipped in Data.panel/Coordinates.stack/Get_Coordinates.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
"""Copies the coordinates of a point the user clicks to the clipboard.

The click runs on the native Measure tool (pynavis.pick.measure_point), so the
snapping to vertices, edges and line ends is the host's own and the point that
reaches the clipboard is the snapped one rather than wherever the cursor
happened to be. It is written in the shape Go to Coordinates reads back:
"X, Y, Z" at three decimals, in model units.

Esc, a right-click or picking another tool cancels and copies nothing, with no
complaint: a cancelled pick is an answer, not a failure. See lib/coords.py
for the formatting.
"""

import coords

from pynavis import app, pick, script, toast


def run():
    doc = app.get_doc()
    log = script.get_logger()

    hit = pick.measure_point('Click a point to copy its coordinates')
    if hit is None:
        return

    units = str(doc.Units)
    text = coords.format_point(hit.point)
    if not script.clipboard_copy(text):
        log.warning('could not copy %s (%s): the clipboard is busy' % (text, units))
        toast.error('Could not copy the coordinates',
                    'Another application is using the clipboard. Try again.')
        return
    log.info('copied %s (%s)' % (text, units))
    toast.success('Coordinates copied', '%s %s' % (text, units))


if '__commandpath__' in globals():
    run()
bundle.yaml The bundle contract: the keys pyNavis reads for this tool. View on GitHub
title: Get Coordinates
tooltip: Click a point in the view and its coordinates go to the clipboard, ready to paste into Go to Coordinates, into a report, or back into the authoring model. The click uses the Measure tool, so the pointer snaps to vertices and edges exactly as a measurement does; Esc or right-click cancels.
context: doc