-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathGetMaterialTexturePath.py
More file actions
34 lines (27 loc) · 1.13 KB
/
GetMaterialTexturePath.py
File metadata and controls
34 lines (27 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
from pxr import UsdShade
# Get stage.
stage = omni.usd.get_context().get_stage()
selection = omni.usd.get_context().get_selection()
paths = selection.get_selected_prim_paths()
for path in paths:
prim = stage.GetPrimAtPath(path)
if not prim.IsA(UsdShade.Material):
continue
# List textures referenced by Material.
pChildren = prim.GetChildren()
for cPrim in pChildren:
if cPrim.IsA(UsdShade.Shader):
shaderPrim = UsdShade.Shader(cPrim)
print(f"[{shaderPrim.GetPath().pathString}]")
mInputs = shaderPrim.GetInputs()
for inputV in mInputs:
baseName = inputV.GetBaseName()
typeName = inputV.GetTypeName()
if typeName == "asset":
v = inputV.Get() # Sdf.AssetPath
if v.path != "":
# v.path ... display path.
# v.resolvedPath ... absolute path.
print(f" {baseName}")
print(f" path [ {v.path} ]")
print(f" resolvedPath [ {v.resolvedPath} ]")