You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/stage-setting/stage.md
+104-5Lines changed: 104 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -31,13 +31,15 @@ kernelspec:
31
31
Welcome to this lesson on OpenUSD {term}`stages <Stage>`, a core element in 3D scene description. Understanding OpenUSD stages enables collaboration across various applications and datasets by allowing us to aggregate our data in one place.
32
32
33
33
In this lesson, we will:
34
-
* Define the role of stages in 3D scene description.
34
+
35
+
- Define the role of stages in 3D scene description.
35
36
36
37
## What Is a Stage?
37
38
38
39
At its core, an OpenUSD stage presents the scenegraph, which dictates what is in our scene. It is the hierarchy of objects, called {term}`prims <Prim>`. These prims can be anything from geometry, to materials, to lights and other organizational elements. This scene is commonly stored in a data structure of connected nodes, which is why we refer to it as the scenegraph.
39
40
40
41
```{kaltura} 1_cm4ehcvo
42
+
41
43
```
42
44
43
45
### How Does It Work?
@@ -65,10 +67,10 @@ Creating a USD stage is the first step to generating a new USD scenegraph. In Py
65
67
```python
66
68
# Create a new, empty USD stage where 3D scenes are assembled
67
69
Usd.Stage.CreateNew()
68
-
70
+
69
71
# Open an existing USD file as a stage
70
72
Usd.Stage.Open()
71
-
73
+
72
74
# Saves all layers in a USD stage
73
75
Usd.Stage.Save()
74
76
```
@@ -80,10 +82,11 @@ Usd.Stage.Save()
80
82
At its core, an OpenUSD [stage](https://openusd.org/release/glossary.html#usdglossary-stage) refers to a top-level USD file that serves as a container for organizing a hierarchy of elements called prims. Stages aren't files, but a unified scenegraph populated from multiple data sources called [layers](https://openusd.org/release/glossary.html#usdglossary-layer).
81
83
82
84
Some of the functions we will use to access the stage will be the following:
85
+
83
86
-[`Usd.Stage.CreateNew()`](https://openusd.org/release/api/class_usd_stage.html#a50c3f0a412aee9decb010787e5ca2e3e): Creates a new empty USD Stage where 3D scenes are assembled.
84
87
-[`Usd.Stage.Open()`](https://openusd.org/release/api/class_usd_stage.html#ad3e185c150ee38ae13fb76115863d108): Opens an existing USD file as a stage.
85
88
-[`Usd.Stage.Save()`](https://openusd.org/release/api/class_usd_stage.html#adefa2f7ebfc4d8c09f0cd54419aa36c4): Saves the current stage of a USD stage back to a file. If there are multiple layers in the stage, all edited layers that contribute to the stage are being saved. In our case, all edits are being done in a single layer.
Here we created a `usda` file using Python, loaded it as a stage, and printed out the stage's contents. Since nothing is in our stage we do not get much from the output.
99
102
100
-
`.usda` are human-readable UTF-8 text. The [Crate file](https://openusd.org/release/glossary.html#crate-file-format) format is USD's own binary file format whose file extension is `.usdc` and is bi-directionally convertible to the `.usda` text format. `.usd` can refer to either Crate or text files.
103
+
```{seealso}
104
+
`.usda` is a human-readable text format for OpenUSD.
A common task when working with OpenUSD is opening an existing file, making changes to the stage, and then saving the result back to disk. The `Usd.Stage.Open()` function loads a USD file as a stage, and `stage.Save()` writes any edits you make to the stage's root layer.
112
+
113
+
In this example, we open an existing USDA file, add a prim so the modification is visible, and then save the updated stage.
Here we opened an existing stage, modified its scenegraph by adding a prim, and saved the result back into the same root layer file. Any edits made to the stage are written to the root layer unless additional layers are introduced.
132
+
133
+
### Example 3: Create a Stage in Memory
101
134
135
+
Sometimes you may want to create a stage without immediately writing it to disk. This is useful when generating temporary data, running tests, or building a stage that you only want to save after validating its contents.
136
+
137
+
The `Usd.Stage.CreateInMemory()` function creates a stage whose root layer exists only in
In this example, the stage begins entirely in memory and is not written to disk until Export() is called. This makes CreateInMemory() useful for temporary stages, procedural generation, and workflows where you want to avoid unnecessary file writes.
158
+
159
+
### Example 4: Working With the Root Layer
160
+
161
+
Every stage has a root layer, which is the first layer opened by the stage.
162
+
Although it acts as the anchor for the layer stack, the majority of authored data may reside in other layers depending on the composition. When you create a stage with CreateNew(), the file you pass becomes its root layer.
163
+
164
+
In this example, we access the root layer directly, inspect its metadata, and add a sublayer to demonstrate how the root layer organizes a stage’s data.
0 commit comments