Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from pxr import Usd, UsdShade
- # Assume stage is your loaded USD stage
- # Replace '/LightPrimPath' and '/ShadingPrimPath' with the actual paths of the light and shading prims
- stage = Usd.Stage.Open("path_to_your_stage.usda")
- light_path = "/LightPrimPath"
- shading_path = "/ShadingPrimPath"
- # Fetch the light prim and the shading prim
- light_prim = stage.GetPrimAtPath(light_path)
- shading_prim = stage.GetPrimAtPath(shading_path)
- # Check if the light prim has the 'inputs:texture:file' attribute
- light_texture_attr = light_prim.GetAttribute("inputs:texture:file")
- if light_texture_attr:
- # Get the value of the attribute
- texture_file = light_texture_attr.Get()
- # Fetch or create the shading prim's 'inputs:file' attribute
- shading_shader = UsdShade.Shader(shading_prim)
- file_attr = shading_shader.CreateInput("file", Sdf.ValueTypeNames.Asset)
- # Apply the texture file path to the 'inputs:file' attribute on the shading prim
- file_attr.Set(texture_file)
- print(f"Applied texture file '{texture_file}' from light prim to shading prim.")
- else:
- print("The light prim does not have an 'inputs:texture:file' attribute.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement