-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathInternalReferenceTest.py
More file actions
35 lines (26 loc) · 913 Bytes
/
InternalReferenceTest.py
File metadata and controls
35 lines (26 loc) · 913 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()
defaultPrimPath = defaultPrim.GetPath().pathString
# Create sphere.
orgPath = defaultPrimPath + '/org'
UsdGeom.Xform.Define(stage, orgPath)
spherePath = orgPath + '/sphere'
sphereGeom = UsdGeom.Sphere.Define(stage, spherePath)
# Set radius.
sphereGeom.CreateRadiusAttr(2.0)
# Set color.
sphereGeom.CreateDisplayColorAttr([(1.0, 0.0, 0.0)])
# Create empty node(Xform).
path = defaultPrimPath + '/refShape'
UsdGeom.Xform.Define(stage, path)
prim = stage.GetPrimAtPath(path)
# Set position.
UsdGeom.XformCommonAPI(prim).SetTranslate((5.0, 0.0, 0.0))
# Remove references.
prim.GetReferences().ClearReferences()
# Add a internal reference.
# The Path to be added must be an Xform.
prim.GetReferences().AddInternalReference(orgPath)