I use this script to add drivers. But after I execute the script, save the file, close blender, and then open the file again, the driver has lost its track. What can I do? Are there any alternatives?
import bpy
# Driver Blur
blur_node = bpy.context.scene.node_tree.nodes["Group"].node_tree.nodes["Blur"]
Driver = blur_node.driver_add('size_x')
Input_name = "Blur 1 Size"
Driver.driver.type = 'AVERAGE'
dif_fac_driver = Driver.driver
var = dif_fac_driver.variables.new() # create variable to use
var.name = f'default_value' # set expression to the variable
# Set target
var.targets[0].id_type = 'NODETREE'
var.targets[0].id = bpy.context.scene.node_tree
var.targets[0].data_path = f'nodes["Group"].inputs["Input"].default_value'