Skip to content

Commit

Permalink
Corrected function names, reorder function calls, and add missing lin…
Browse files Browse the repository at this point in the history
…es of code (#16)

* Fix typos

* Fix undefined prim_spec when printing

* Bind material
  • Loading branch information
mrowdy authored Jun 21, 2024
1 parent 7f94a32 commit 414f607
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 @@ -475,7 +475,7 @@ def "cube" (
stage = Usd.Stage.CreateInMemory()
prim_path = Sdf.Path("/bicycle")
prim = stage.DefinePrim(prim_path, "Xform")
prim.ApplyAPI("UsdGeomModelAPI")
prim.ApplyAPI("GeomModelAPI") # Older USD versions: prim.ApplyAPI("UsdGeomModelAPI")
prim_def = prim.GetPrimDefinition()
print(prim_def.GetAppliedAPISchemas()) # Returns: ['GeomModelAPI']
print(prim_def.GetPropertyNames())
Expand Down Expand Up @@ -533,7 +533,7 @@ def "cube" (
## Payload loading: Control payload loading (High Level only as it redirects the request to the stage).
# In our example stage here, we have no payloads, so we don't see a difference.
prim.Load()
prim.UnLoad()
prim.Unload()
# Calling this on the prim is the same thing.
prim = stage.GetPrimAtPath(prim_path)
prim.GetStage().Load(prim_path)
Expand Down Expand Up @@ -2422,13 +2422,16 @@ def "prim" (

#// ANCHOR: metadataPlugin
from pxr import Usd, Sdf
# To see all the globally registered fields for the metadata on prim specs:
print(Sdf.PrimSpec.GetMetaDataInfoKeys(prim_spec))

# Here we test it in an example stage:
stage = Usd.Stage.CreateInMemory()
layer = stage.GetEditTarget().GetLayer()
prim = stage.DefinePrim("/prim")
prim_spec = layer.GetPrimAtPath(prim.GetPath())

# To see all the globally registered fields for the metadata on prim specs:
print(Sdf.PrimSpec.GetMetaDataInfoKeys(prim_spec))

# Float field
metadata_name = "usdSurvivalGuideFloat"
print(prim.GetMetadata(metadata_name)) # Returns: None
Expand Down Expand Up @@ -2474,7 +2477,7 @@ def "prim" (
# Note the method signature takes a time code as an input. If you supply a default time code
# value clips will be stripped from the result.
time_code = Usd.TimeCode(1001)
print(prim.GetPropertyStack(time_code))
print(attr.GetPropertyStack(time_code))
### Low Level ###
# The low level API does not offer any "extras" worthy of noting.
#// ANCHOR_END: propertyOverview
Expand Down Expand Up @@ -3093,6 +3096,7 @@ def "prim" (
# Bind materials via direct binding
material = UsdShade.Material(material_prim)
mat_bind_api = UsdShade.MaterialBindingAPI.Apply(render_prim)
mat_bind_api.Bind(material)
# Unbind all
mat_bind_api.UnbindAllBindings()
# Bind via collection
Expand Down

0 comments on commit 414f607

Please sign in to comment.