-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathMovePrim.py
More file actions
33 lines (24 loc) · 804 Bytes
/
MovePrim.py
File metadata and controls
33 lines (24 loc) · 804 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from pxr import UsdGeom
import omni.kit
import omni.usd
# Get stage.
stage = omni.usd.get_context().get_stage()
# Get default prim.
defaultPrim = stage.GetDefaultPrim()
# Create empty node(Xform).
defaultPrimPath = defaultPrim.GetPath().pathString
xformPath = f"{defaultPrimPath}/Xform"
UsdGeom.Xform.Define(stage, xformPath)
# Get selection.
selection = omni.usd.get_context().get_selection()
selectedPaths = selection.get_selected_prim_paths()
for path in selectedPaths:
# Get prim.
prim = stage.GetPrimAtPath(path)
if not prim.IsValid():
continue
pathTo = f"{xformPath}/{prim.GetName()}"
# Change Prim's path.
# path_from : Path of the original Prim.
# path_to : Path to move to.
omni.kit.commands.execute("MovePrim", path_from=path, path_to=pathTo)