Replicator fails to set material properties that are in a default state

IsaacSim 5.1 and 6.0

Work Flow:

shader_prim = rep.get.prim_at_path("/World/Looks/Aluminum_Polished/Shader")

def rand_colors():
    lower_bound = (0.0, 0.0, 0.4) 
    upper_bound = (0.2, 0.3, 1.0)	
    with shader_prim:                     
        rep.modify.attribute("inputs:diffuse_tint", rep.distribution.uniform(lower_bound,upper_bound))


  1. The resulting Omnigraph Write node that gets created will error saying that inputs:diffuse_tint does not work.

  2. Open the shader and change the value of diffuse tint.

  3. Omnigraph no longer complains and the color changes as expected.

This is a similar issue that we see in the Variant editor where it fails to add properties from materials unless the user has “touched” or modified them in the interface.

Can you try running this little function make_asset_attr_accessible in your script? I’ve seen this issue before, and it seems similar. Let me know.

import glob
import re
import os
from pathlib import Path
from pxr import Usd, UsdGeom, Gf, Sdf, Vt
import omni.usd
import omni.replicator.core as rep 

def make_asset_attr_accessible(prim, attribute_name, attr_value):
    if not prim.GetAttribute(attribute_name).IsValid():
        prim.CreateAttribute(attribute_name, Sdf.ValueTypeNames.Asset, custom=True).Set(attr_value)
        print(f'Set prim for {attribute_name}')

stage = omni.usd.get_context().get_stage()  

# Create a material
pbr_mat = rep.create.material_omnipbr(count=1)
pbr_primpath = '/Replicator/Looks/OmniPBR/Shader'
pbr_shader_prim = stage.GetPrimAtPath(pbr_primpath)
pbr_shader = rep.get.prims(path_pattern=pbr_primpath)   

# Create the primvars on the material - this is to work around an optimization where attributes aren't settable via script until they're viewed in GUI. The workaround is to create them on the prim, then they can be set.
make_asset_attr_accessible(pbr_shader_prim, "inputs:normalmap_texture", "")