I would like to rewrite the following script so that I can set the color of the material using a hex value; currently it works with RGB.
A search of the literature provides no suggestions as to how to proceed.
Any advice would be much appreciated!
def add_material(obj, material_name, r, g, b):
material = bpy.data.materials.get(material_name)
if material is None:
material = bpy.data.materials.new(material_name)
material.use_nodes = True
principled_bsdf = material.node_tree.nodes['Principled BSDF']
if principled_bsdf is not None:
principled_bsdf.inputs[0].default_value = (r, g, b, 1)
obj.active_material = material