Material clear error

np.clearMaterial()
myValueMaterial.clearAmbient()

error:

AssertionError: !is_attrib_locked() at line 103 of **** \material.I

As soon as a material is attached to an object, it is “locked”, meaning that the set of material properties may not longer be changed (but their values can). The main reason is that the Shader Generator requires a shader regeneration when a material removes or adds a component, and it cannot detect when these changes happened.

Materials aren’t reference counted so a material doesn’t become “unlocked” when it is removed from a model.

You have several options here:

  • You could call set_ambient((0, 0, 0, 0)) instead
  • You could replace it with a different material, making a copy
  • You could set the config var enforce-attrib-lock to false. You should only do this if you don’t use the Shader Generator.