Build a id to node mapping in a USD file.
Nodes without IDs are ignored.
Returns:
Name | Type | Description |
dict | | Mapping of id to nodes in the USD file. |
Source code in client/ayon_maya/tools/mayalookassigner/usd.py
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38 | def get_usd_ids_cache(path):
# type: (str) -> dict
"""Build a id to node mapping in a USD file.
Nodes without IDs are ignored.
Returns:
dict: Mapping of id to nodes in the USD file.
"""
if not is_usd_lib_supported:
raise RuntimeError("No pxr.Usd python library available.")
stage = Usd.Stage.Open(path)
ids = {}
for prim in stage.Traverse():
attr = prim.GetAttribute("userProperties:cbId")
if not attr.IsValid():
continue
value = attr.Get()
if not value:
continue
path = str(prim.GetPath())
ids[path] = value
cache = defaultdict(list)
for path, value in ids.items():
cache[value].append(path)
return dict(cache)
|