How to change properties of loaded material?

Hello,

To make the loaded object to have specular surface, I tried to change the metallic and specular property of the loaded material.

cur_mat, _ = UsdShade.MaterialBindingAPI(prim).ComputeBoundMaterial()
cur_mat.GetInput("metallic_constant").Set(1.0)
cur_mat.GetInput("specular_level").Set(1.0)
                    
UsdShade.MaterialBindingAPI(prim).Bind(cur_mat, UsdShade.Tokens.strongerThanDescendants)

But error happens when calling Set:

Used null prim - UsdExpiredPrimAccessError thrown:
 -> Usd_ThrowExpiredPrimAccessError at /buildAgent/work/ac88d7d902b57417/USD/pxr/usd/usd/primData.cpp:257 from
     #0   0x00007f0295d6242d in pxrInternal_v0_22__pxrReserved__::UsdAttribute::GetTypeName() const+0x5d
     #1   0x00007f02119f0762 in boost::python::objects::caller_py_function_impl<boost::python::detail::caller<bool (*)(pxrInternal_v0_22__pxrReserved__::UsdShadeInput const&, boost::python::api::object, pxrInternal_v0_22__pxrReserved__::UsdTimeCode const&), boost::python::default_call_policies, boost::mpl::vector4<bool, pxrInternal_v0_22__pxrReserved__::UsdShadeInput const&, boost::python::api::object, pxrInternal_v0_22__pxrReserved__::UsdTimeCode const&> > >::operator()(_object*, _object*)+0xc2
     #2   0x00007f02a43342ed in boost::python::objects::function::call(_object*, _object*) const+0x33d
     #3   0x00007f02a433ac9b in boost::python::detail::exception_handler::operator()(boost::function0<void> const&) const+0x4b
     #4   0x00007f025f63dd43 in boost::detail::function::function_obj_invoker2<boost::_bi::bind_t<bool, 

@mssonglin from an older doc, but it should give you an idea how to create, modify, and assign the material:

https://omniverse-content-production.s3-us-west-2.amazonaws.com/Assets/Isaac/Documentation/Isaac-Sim-Docs_2022.2.1/isaacsim/latest/reference_python_snippets.html#creating-modifying-assigning-materials

alternatively, you can also use the kit command to ‘record’ the code if you are looking to achieve desired function programmatically.

i am sure the mods/devs could provide more straightforward solution.

Also, same information available in latest docs: Scene Setup — Omniverse IsaacSim latest documentation

that’s where they are. still trying to get used to the new layout, thanks for the assist!