---
title: "snapToRigid"
canonical: "https://help.vicon.com/space/ShogunPost121/1253737073/snapToRigid"
format: markdown
---
# Description

Snaps a named node to a position and/or rotation formed by a rigid body defined from the currently selected nodes.

Use snapToRigid when you need to constrain a node to a location defined by a rigid body operation.

If neither option for `allTime` or `ranges` is used, then the operation will affect the current frame only.

The units for the `-absolute` option are millimeters.

Values for the default relative option are a percentage of the distance from the first selected node to the second selected node.

Use of the `-positionOnly` option prevents rigid body rotations from being applied to the target node. This option can be useful when you want to snap an object, like a baseball bat to a new location while maintaining the rotational orientation of the bat.

snapToRigid is different from [snapToSystem](https://vicon-help.atlassian.net/wiki/spaces/ShogunPost121/pages/1253737770) and [snapToSystemAlign](https://vicon-help.atlassian.net/wiki/spaces/ShogunPost121/pages/1253737280) in that snapToRigid defines a rigid body out of the selected markers and uses its coordinate system. The rigid body is defined at a frame the command determines. snapToSystem and snapToSystemAlgin do not use a rigid body, they refine the coordinate system at each frame.

## Functional area

Snap

# Command syntax

## Syntax

> Macro (scroll-tablelayout)

|  |
| --- |
| `snapToRigid "targetNodeName" xOffset yOffset zOffset [-allTime] [-ranges] [-absolute] [-positionOnly]` |

> Macro (scroll-pagebreak)

### Arguments

> Macro (scroll-tablelayout)

| Name | Type | Required | Comments |
| --- | --- | --- | --- |
| `zOffset` | float | yes | Specifies the position offset to apply to the object being snapped on the Z axis of the space defined by the selected markers. |
| `yOffset` | float | yes | Specifies the position offset to apply to the object being snapped on the Y axis of the space defined by the selected markers. |
| `xOffset` | float | yes | Specifies the position offset to apply to the object being snapped on the X axis of the space defined by the selected markers. |
| `targetNodeName` | string | yes | Name of the node that will be snapped. |

### Flags

> Macro (scroll-tablelayout)

| Name | Flag arguments | Argument type | Exclusive to | Comments |
| --- | --- | --- | --- | --- |
| `all time` | 0 | — | ranges | Performs the snap over the entire animation range. |
| `positionOnly` | 0 | — | rotationOnly | Only modifies the position of the node being snapped. |
| `rotationOnly` | 0 | — | positionOnly | Only modifies the rotation of the node being snapped. |
| `absolute` | 0 | — | — | Specifies the offset is in mm rather then a percentage of the distance between the first two nodes that define the system. |
| `ranges` | 0 | — | allTime | Performs the snap over the selected time ranges. |

## Return value

void 

> Macro (scroll-pagebreak)

## Examples

```plaintext
// This sequence of commands will create a new Marker node
// and snap its position over all time to a position offset by
// the indicated number of millimeters ( -50 in X, 50 in Y, 
// and 50 in Z) calculated from the origin of a temporary rigid
// body created from LFWT, LMWT, and LBWT. The offset is applied
// in the local coordinate system of the temporary rigid body.
// The rigid body coordinate system is then expressed in rotations
// relative to world space and applied to the target node,
// snapRigidTest.
create Marker snapRigidTest;
select LFWT LMWT LBWT;
snapToRigid -allTime -absolute snapRigidTest -50 50 50;
```

# Additional information

## Related commands

- [snapTo](https://vicon-help.atlassian.net/wiki/spaces/ShogunPost121/pages/1253737795)
- [snapToConstraint](https://vicon-help.atlassian.net/wiki/spaces/ShogunPost121/pages/1253736474)
- [snapToLine](https://vicon-help.atlassian.net/wiki/spaces/ShogunPost121/pages/1253736528)
- [snapToLocal](https://vicon-help.atlassian.net/wiki/spaces/ShogunPost121/pages/1253736854)
- [snapToSystem](https://vicon-help.atlassian.net/wiki/spaces/ShogunPost121/pages/1253737770)
- [snapToSystemAlign](https://vicon-help.atlassian.net/wiki/spaces/ShogunPost121/pages/1253737280)