Docs: Include get_prim_map() in bpy.types.USDHook example code

Provide an example of using the `get_prim_map()` in the existing USD
Hook sample.

Related: blender/blender@0df5d8220b

Pull Request: https://projects.blender.org/blender/blender/pulls/146866
This commit is contained in:
Nick Alberelli
2025-09-27 01:58:44 +02:00
committed by Jesse Yurkovich
parent 4bb6513b7d
commit db88381e75

View File

@@ -245,8 +245,28 @@ class USDHookExample(bpy.types.USDHook):
@staticmethod @staticmethod
def on_import(import_context): def on_import(import_context):
""" Create a text object to display the stage's custom data. """Inspect the imported stage & objects to set some custom data
""" """
###########################################################
# Store some USD metadata on each imported data block.
###########################################################
prim_map = import_context.get_prim_map()
# Store prim path as a string on each data block created.
for prim_path, data_blocks in prim_map.items():
# Type hints for prim map.
prim_path: Sdf.Path
data_blocks: list[bpy.types.ID]
# Loop over mapped data blocks to store some metadata.
for data_block in data_blocks:
data_block["prim_path"] = str(prim_path)
###########################################################
# Create a text object to display the stage's custom data.
###########################################################
stage = import_context.get_stage() stage = import_context.get_stage()
if stage is None: if stage is None: