Pivot Tool¶
The Pivot Tool is an extension that allows the user to adjust the pivot of a prim.
Programming Guide¶
The Pivot Tool can also be used without the UI via Omniverse Commands. This way, other scripts and extensions can adjust the pivot of objects without having to load the extension or use the UI.
The PivotToolAddPivot
command is used to add the Pivot transform to a given set of prims. It expects the following arguments:
Argument |
Description |
---|---|
prim_paths (list[str]) |
The list of prims to array. Expects prim paths, not prims.
|
Optional Argument |
Description |
---|---|
center_pivot (bool) |
Added pivots will be automatically centered in the bounding box.
|
context (str) |
The USD context where this command should be used - allows for this command to be used by multiple USD contexts simultaneously.
|
The PivotToolRemovePivot
command is used to remove the Pivot transform to a given set of prims. It expects the following arguments:
Argument |
Description |
---|---|
prim_paths (list[str]) |
The list of prims to array. Expects prim paths, not prims.
|
maintain_position (bool) |
Modify TranslateOp to avoid drift. (True by default)
|
bbox_includes_child_prims (bool) |
Bounding box is extended to include Xformable child Prims. (True by default)
|
Optional Argument |
Description |
---|---|
context (str) |
The USD context where this command should be used - allows for this command to be used by multiple USD contexts simultaneously.
|
The PivotToolUpdatePivot
command is used to update the PivotOp transforms of a given set of prims. It expects the following arguments:
Argument |
Description |
---|---|
prim_paths (list[str]) |
The list of prims to array. Expects prim paths, not prims.
|
new_pivot_position (Gf.Vec3d) |
New Pivot position to set all Pivots to.
|
use_normalized_position (bool) |
Position values are normalized and relative to each Prim’s bounding box. (True by default)
|
maintain_position (bool) |
Modify TranslateOp to avoid drift. (True by default)
|
bbox_includes_child_prims (bool) |
Bounding box is extended to include Xformable child Prims. (True by default)
|
auto_enable_pivots (bool) |
Automatically enable any disabled PivotOps. (True by default)
|
Optional Argument |
Description |
---|---|
context (str) |
The USD context where this command should be used - allows for this command to be used by multiple USD contexts simultaneously.
|
The PivotToolSetPivotFromWorldPosition
command is used to set the Pivot position of a given set of prims from an arbitrary World Position. It expects the following arguments:
Argument |
Description |
---|---|
prim_paths (list[str]) |
The list of prims to array. Expects prim paths, not prims.
|
world_position (Gf.Vec3d) |
World position to apply to each PivotOp.
|
maintain_position (bool) |
Modify TranslateOp to avoid drift. (True by default)
|
bbox_includes_child_prims (bool) |
Bounding box is extended to include Xformable child Prims. (True by default)
|
auto_enable_pivots (bool) |
Automatically enable any disabled PivotOps. (True by default)
|
Optional Argument |
Description |
---|---|
context (str) |
The USD context where this command should be used - allows for this command to be used by multiple USD contexts simultaneously.
|
The PivotToolSetPivotFromPrimWorldPosition
command is used to set the Pivot position of a given set of prims from an arbitrary World Position. It expects the following arguments:
Argument |
Description |
---|---|
prim_paths (list[str]) |
The list of prims to array. Expects prim paths, not prims.
|
world_position_prim_path (str) |
Path of prim whose world position to apply to each PivotOp.
|
maintain_position (bool) |
Modify TranslateOp to avoid drift. (True by default)
|
bbox_includes_child_prims (bool) |
Bounding box is extended to include Xformable child Prims. (True by default)
|
auto_enable_pivots (bool) |
Automatically enable any disabled PivotOps. (True by default)
|
Optional Argument |
Description |
---|---|
context (str) |
The USD context where this command should be used - allows for this command to be used by multiple USD contexts simultaneously.
|
The PivotToolSetPivotToBoundingBoxBase
command is used to set the Pivot position of a given set of prims to the bottom center of their respective bounding boxes. It expects the following arguments:
Argument |
Description |
---|---|
prim_paths (list[str]) |
The list of prims to array. Expects prim paths, not prims.
|
maintain_position (bool) |
Modify TranslateOp to avoid drift. (True by default)
|
bbox_includes_child_prims (bool) |
Bounding box is extended to include Xformable child Prims. (True by default)
|
auto_enable_pivots (bool) |
Automatically enable any disabled PivotOps. (True by default)
|
Optional Argument |
Description |
---|---|
context (str) |
The USD context where this command should be used - allows for this command to be used by multiple USD contexts simultaneously.
|
The PivotToolSetPivotToBoundingBoxCenter
command is used to set the Pivot position of a given set of prims to the center of their respective bounding boxes. It expects the following arguments:
Argument |
Description |
---|---|
prim_paths (list[str]) |
The list of prims to array. Expects prim paths, not prims.
|
maintain_position (bool) |
Modify TranslateOp to avoid drift. (True by default)
|
bbox_includes_child_prims (bool) |
Bounding box is extended to include Xformable child Prims. (True by default)
|
auto_enable_pivots (bool) |
Automatically enable any disabled PivotOps. (True by default)
|
Optional Argument |
Description |
---|---|
context (str) |
The USD context where this command should be used - allows for this command to be used by multiple USD contexts simultaneously.
|
The PivotToolResetPivot
command is used to reset the Pivot position of a given set of prims to zero values. It expects the following arguments:
Argument |
Description |
---|---|
prim_paths (list[str]) |
The list of prims to array. Expects prim paths, not prims.
|
maintain_position (bool) |
Modify TranslateOp to avoid drift. (True by default)
|
bbox_includes_child_prims (bool) |
Bounding box is extended to include Xformable child Prims. (True by default)
|
auto_enable_pivots (bool) |
Automatically enable any disabled PivotOps. (True by default)
|
Optional Argument |
Description |
---|---|
context (str) |
The USD context where this command should be used - allows for this command to be used by multiple USD contexts simultaneously.
|
Below is an example code block where we call the PivotToolAddPivot
and pass in the expected target prims. Then we call PivotToolSetPivotFromWorldPosition
and set the pivot of the target prims to a set of world coordinates.
"""
This is a simple example that uses omni.tools.pivot to add a pivot to a list of prims via command, then move the pivot to a given position in the world.
"""
from pxr import Gf
prims = []
prims.append("/World/Cube")
pos = Gf.Vec3d(10, 10, 10)
omni.kit.commands.execute("PivotToolAddPivot", prim_paths=prims)
omni.kit.commands.execute("PivotToolSetPivotFromWorldPosition", prim_paths=prims, world_position=pos)
Features Supported¶
Works on most USD Xformable types, including xforms, meshes, shapes, and skeletons.
Works on all prim types, including instanceable, referenced, and payloads.
Supports undo and redo of operations, both from the UI and via command.
Limitations¶
Does not work on light or camera prims.
Prims need to have a valid full XformOp stack.