---
title: "getDistance"
canonical: "https://help.vicon.com/space/Shogun17/13536319/getDistance"
format: markdown
---
# Description

Measures the distance between two nodes in a scene.

The default behavior (no flags used) returns the distance at the current frame. The `-avg`, `-min`, `-max`, `-range`, and `-sd` flags all return a value that's based on a number of frames. That number of frames is the play range by default unless the `-rangesOnly` option is used.

## Functional area

Data retrieval

# Command syntax

## Syntax

|  |
| --- |
| `getDistance node1 node2 [-avg] [-min] [-max] [-range] [-sd] [-rangesOnly] [-mustHaveKeys]` |

### Arguments

| **Name** | **Type** | **Required** | **Comments** |
| --- | --- | --- | --- |
| `node1` | string | yes | Node to measure from |
| `node2` | string | yes | Node to measure to |

### Flags

> Macro (scroll-tablelayout)

| **Name** | **Flag arguments** | **Argument type** | **Exclusive to** | **Comments** |
| --- | --- | --- | --- | --- |
| `-avg` | 0 | — | -min, -max, -range, -sd | Returns the average distance |
| `-min` | 0 | — | -avg, -max, -range, -sd | Returns the minimum distance |
| `-max` | 0 | — | -avg, -min, -range, -sd | Returns the maximum distance |
| `-range` | 0 | — | -avg, -min, -max, -sd | Returns the difference of the min and max |
| `-sd` | 0 | — | -avg, -min, -max, -range | Returns the standard deviation |
| `-rangesOnly` | 0 | — | — | Computes distance calculations over the selected time ranges only |
| `-mustHaveKeys` | 0 | — | — | Only computes distance on frames where both nodes have a key present |

## Return value

float

Returns the distance in mm from node1 to node2

## Examples

```plaintext
// create a clip
create Clip Clip_1;
 
// create two objects which we want to compute distances between 
create Marker Marker_1;
create Bone Bone_1;
 
// move the bone 300 and 400 in x, y (respectively
setKey "Translation.X" 300 -onMod Bone_1;
setKey "Translation.Y" 400 -onMod Bone_1;
 
// show that the bone is 500 mm away from the marker as expected
print(getDistance("Marker_1", "Bone_1"));
```

# Additional information

## Related commands

- [getLength](https://vicon-help.atlassian.net/wiki/spaces/Shogun17/pages/13536603)