-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathGetJoints.py
More file actions
51 lines (36 loc) · 1.58 KB
/
GetJoints.py
File metadata and controls
51 lines (36 loc) · 1.58 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
from pxr import Usd, UsdGeom, UsdPhysics, UsdShade, Sdf, Gf, Tf
# Get stage.
stage = omni.usd.get_context().get_stage()
# Get selection.
selection = omni.usd.get_context().get_selection()
paths = selection.get_selected_prim_paths()
# -------------------------------------------------------------------.
# Traverse.
# -------------------------------------------------------------------.
def Traverse(prim):
if prim.IsValid() == None:
return
# For Skeleton, get the Joints information.
if prim.GetTypeName() == 'Skeleton':
jointAttr = prim.GetAttribute("joints")
bindTransformsAttr = prim.GetAttribute("bindTransforms")
restTransformsAttr = prim.GetAttribute("restTransforms")
if jointAttr.IsValid() and bindTransformsAttr.IsValid() and restTransformsAttr.IsValid():
jCou = len(jointAttr.Get())
print("[ " + prim.GetPath().pathString + " ]")
for i in range(jCou):
jointName = jointAttr.Get()[i]
bindTransform = bindTransformsAttr.Get()[i]
restTransform = restTransformsAttr.Get()[i]
print(str(i) + " : " + jointName)
print(" bindTransform : " + str(bindTransform))
print(" restTransform : " + str(restTransform))
# Recursively traverse the hierarchy.
pChildren = prim.GetChildren()
for cPrim in pChildren:
Traverse(cPrim)
# -------------------------------------------------------------------.
for path in paths:
# Get prim.
prim = stage.GetPrimAtPath(path)
Traverse(prim)