User input to change materials properties I have been struglin with this and I can’t find a way to do it. :(
I have made a script that takes care of resetting the values of some of material properties in the whole scene, but now I would like to let the user to decide what is the new default value for all those properties. Since some materials could have their own texture map attached I can not delete all the materials a assing a new one with new values.
Specifically I would want to let the user change the values for the node input [4], [5] and [7]
Could anyone shed some light on this:
import bpy


class ResetAllMaterialsOperator(bpy.types.Operator):
  &quot;&quot;&quot;Affects all Materials in the scene&quot;&quot;&quot;
  bl_idname = &quot;material.reset_all_materials_operator&quot;
  bl_label = &quot;Reset all Materials&quot;
  bl_options = {'REGISTER', 'UNDO'}

  def execute(self, context):
    for mat in bpy.data.materials:
        if mat.use_nodes:
            for n in mat.node_tree.nodes:
                if n.type == &quot;BSDF_PRINCIPLED&quot; and n.label == &quot;&quot;:
                        n.inputs[4].default_value = 0.75
                        n.inputs[5].default_value = 0.1
                        n.inputs[7].default_value = 0.5
                        
                        
                        
                        for l in mat.node_tree.links:
                            if l.from_node.type == &quot;TEX_IMAGE&quot; and l.to_node.type == &quot;BSDF_PRINCIPLED&quot;:
                                if l.to_socket.identifier == &quot;Alpha&quot;:
                                    mat.node_tree.links.remove(l)
                        break
                    
                                    
    return {'FINISHED'}



class testPanel(bpy.types.Panel):
    bl_space_type = 'VIEW_3D'
    bl_region_type = 'UI'
    bl_category = &quot;TEST 2&quot;
    bl_label = &quot;Test label&quot;

    def draw(self, context):
        layout = self.layout

        box = layout.box()
        row = box.column()
        row.operator(&quot;material.reset_all_materials_operator&quot;)


def register():
    bpy.utils.register_class(testPanel)
    bpy.utils.register_class(ResetAllMaterialsOperator)
    


def unregister():
    bpy.utils.unregister_class(testPanel)
    bpy.utils.unregister_class(ResetAllMaterialsOperator)
    
    
    
    
if __name__ == &quot;__main__&quot;:
    register()

Thanks in advance,
Juan
Annotate your operator.
Add properties to the operator containing the defaults to set, which can in themselves be set.
Have added the only the metallic property, and a draw method,

add more to suit.
import bpy
from bpy.props import FloatProperty

class ResetAllMaterialsOperator(bpy.types.Operator):
    &quot;&quot;&quot;Affects all Materials in the scene&quot;&quot;&quot;
    bl_idname = &quot;material.reset_all_materials_operator&quot;
    bl_label = &quot;Reset all Materials&quot;
    bl_options = {'REGISTER', 'UNDO'}

    metallic = FloatProperty(
            name=&quot;Metallic&quot;,
            default=0.75,
            )
    
    def draw(self, context):
        self.layout.prop(self, &quot;metallic&quot;)
           
    def execute(self, context):
        for mat in bpy.data.materials:
            if mat.use_nodes:
                for n in mat.node_tree.nodes:
                    if n.type == &quot;BSDF_PRINCIPLED&quot; and n.label == &quot;&quot;:


                        n.inputs[4].default_value = self.metallic
                        n.inputs[5].default_value = 0.1
                        n.inputs[7].default_value = 0.5

                        for l in mat.node_tree.links:
                            if l.from_node.type == &quot;TEX_IMAGE&quot; and l.to_node.type == &quot;BSDF_PRINCIPLED&quot;:
                                if l.to_socket.identifier == &quot;Alpha&quot;:
                                    mat.node_tree.links.remove(l)
                        break

        return {'FINISHED'}


class TestPanel(bpy.types.Panel):
    bl_space_type = 'VIEW_3D'
    bl_region_type = 'UI'
    bl_idname = &quot;TEST_PT_test&quot;
    bl_category = &quot;TEST 2&quot;
    bl_label = &quot;Test label&quot;

    def draw(self, context):
        layout = self.layout

        box = layout.box()
        row = box.column()
        row.operator(&quot;material.reset_all_materials_operator&quot;)

classes = (TestPanel,  ResetAllMaterialsOperator)

def register():
    for cls in classes:
        bpy.utils.register_class(cls)


def unregister():
    for cls in reversed(classes):
        bpy.utils.unregister_class(cls)


if __name__ == &quot;__main__&quot;:
    register()