Skip to content

Commit

Permalink
Fix stage and layer related typos
Browse files Browse the repository at this point in the history
  • Loading branch information
LucaScheller committed Sep 22, 2023
1 parent c09d5d3 commit 4463eea
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions code/core/elements.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,8 +288,10 @@ def example():
# The .DefinePrim method uses a Sdf.SpecifierDef specifier by default
prim = stage.DefinePrim(prim_path, "Xform")
prim.SetSpecifier(Sdf.SpecifierOver)
# or
prim = stage.OverridePrim(prim_path)
# The prim class' IsDefined method checks if a prim (and all its parents) have the "def" specifier.
print(prim.GetSpecifier() == Sdf.SpecifierSdf, prim.IsDefined())
print(prim.GetSpecifier() == Sdf.SpecifierOver, not prim.IsDefined() and not prim.IsAbstract())

### Low Level ###
from pxr import Sdf
Expand All @@ -307,7 +309,9 @@ def example():
prim_path = Sdf.Path("/bicycle")
# The .DefinePrim method uses a Sdf.SpecifierDef specifier by default
prim = stage.DefinePrim(prim_path, "Xform")
prim.SetSpecifier(Sdf.SpecifierOver)
prim.SetSpecifier(Sdf.SpecifierClass)
# or
prim = stage.CreateClassPrim(prim_path)
# The prim class' IsAbstract method checks if a prim (and all its parents) have the "Class" specifier.
print(prim.GetSpecifier() == Sdf.SpecifierClass, prim.IsAbstract())

Expand Down Expand Up @@ -484,7 +488,7 @@ def "cube" (
"""
# You can also bake down the prim definition, this won't flatten custom properties though.
dst_prim = stage.DefinePrim("/flattenedExample")
dst_prim = prim_def.FlattenTo("/flattenedExample")
dst_prim = prim_def.FlattenTo(dst_prim)
# This will also flatten all metadata (docs etc.), this should only be used, if you need to export
# a custom schema to an external vendor. (Not sure if this the "official" way to do it, I'm sure
# there are better ones.)
Expand Down Expand Up @@ -729,12 +733,12 @@ def "cube" (
layer = stage.GetRootLayer()
metadata = layer.customLayerData
metadata["myCustomRootData"] = 1
layer.metadata = metadata
layer.customLayerData = metadata
# Or:
layer = stage.GetSessionLayer()
metadata = layer.customLayerData
metadata["myCustomSessionData"] = 1
layer.metadata = metadata
layer.customLayerData = metadata
# To get the value from the session/root layer depending on the edit target:
stage.GetMetadata("customLayerData")
#// ANCHOR_END: metadataStage
Expand Down

0 comments on commit 4463eea

Please sign in to comment.