-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathflatten_sublayers.py
More file actions
31 lines (23 loc) · 900 Bytes
/
flatten_sublayers.py
File metadata and controls
31 lines (23 loc) · 900 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
from pxr import Usd
import omni.usd
import omni.kit.commands
"""
Flatten sublayers into the root layer using the Omniverse Kit command.
This sample calls the Omniverse application command `FlattenLayers`
via `omni.kit.commands.execute(...)`. This is an application-level
operation (Kit) — not pure USD API.
Usage: run inside Omniverse (Kit) context.
"""
stage = omni.usd.get_context().get_stage()
rootLayer = stage.GetRootLayer()
print("Before flatten, sublayers:")
for p in rootLayer.subLayerPaths:
print(" -", p)
# Call the Omniverse Kit command that performs a proper flatten/merge
# of sublayers into the root layer. This delegates the merge operation
# to the Kit application which knows how to compose and write the
# resulting root layer contents.
omni.kit.commands.execute("FlattenLayers")
print("After flatten, sublayers:")
for p in rootLayer.subLayerPaths:
print(" -", p)