Setting Properties on Material Instances

I played around with this and got the following to work, not sure if this will work for you. I tried to use the set_editor_property and could not get anything to work either.



paramInfo = instance.scalar_parameter_values
print paramInfo
#LogPython: {parameter_info: {name: "testVal", association: GlobalParameter, index: -1}, parameter_value: 1.000000}, {parameter_info: {name: "RefractionDepthBias", association: GlobalParameter, index: -1}, parameter_value: 0.000000}]

#because i got an array, i need to check and make sure i am adjusting the right one.
for i in range(len(paramInfo)):
   if paramInfo*.parameter_info.name == "testVal":
      print "Found Parameter"
      newParams = paramInfo*  #i made a copy
      newParams.parameter_value = 1.2 # adjusted the value
      paramInfo* = newParams #copied all the values back to the array

print instance.get_scalar_parameter_value("testVal")
#LogPython: 1.20000004768


After running the above code i reloaded the material instance in the material editor and the values changed. Note: For some reason if the material instance was already loaded and you run the code, the changes do happen behind the scenes, but don’t show up in the editor until you reload it. Meaning you need to close and double click on the material instance again to see the changes