-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathCreateHierarchy.py
More file actions
35 lines (25 loc) · 856 Bytes
/
CreateHierarchy.py
File metadata and controls
35 lines (25 loc) · 856 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
32
33
34
35
from pxr import Usd, UsdGeom, UsdPhysics, UsdShade, Sdf, Gf, Tf
# Get stage.
stage = omni.usd.get_context().get_stage()
# Get default prim.
defaultPrim = stage.GetDefaultPrim()
# Get root path.
rootPath = ''
if defaultPrim.IsValid():
rootPath = defaultPrim.GetPath().pathString
# Create empty node(Xform).
UsdGeom.Xform.Define(stage, rootPath + '/node1')
# Create empty node(Xform).
UsdGeom.Xform.Define(stage, rootPath + '/node1/node1_2')
# Create sphere.
pathName = rootPath + '/node1/sphere'
sphereGeom = UsdGeom.Sphere.Define(stage, pathName)
# Set radius.
sphereGeom.CreateRadiusAttr(1.0)
# Set position.
UsdGeom.XformCommonAPI(sphereGeom).SetTranslate((-3, 0, 0))
# Create cube.
pathName = rootPath + '/node1/cube'
cubeGeom = UsdGeom.Cube.Define(stage, pathName)
# Set position.
UsdGeom.XformCommonAPI(cubeGeom).SetTranslate((0, 0, 0))