Skip to content

Instantly share code, notes, and snippets.

@CGArtPython
Created November 26, 2024 07:09
Show Gist options
  • Save CGArtPython/67cedb36a0c5a79ac9e93b3e0a147d30 to your computer and use it in GitHub Desktop.
Save CGArtPython/67cedb36a0c5a79ac9e93b3e0a147d30 to your computer and use it in GitHub Desktop.
[Blender Python] How to apply a driver to a compositor node (video explinaiton here https://www.skool.com/cgpython/how-to-add-drivers-to-node-group-sockets-using-python?p=71dfec91 )
"""prerequisite: you have a group node in the compositor, and inside the group node you have a Blur node""
import bpy
tree = bpy.context.scene.node_tree
driver = tree.nodes['Group'].node_tree.nodes['Blur'].driver_add("size_y").driver
driver.type = 'AVERAGE'
var = driver.variables.new()
var.name = "default_value"
var.targets[0].id_type = 'SCENE'
var.targets[0].id = bpy.context.scene
var.targets[0].data_path = 'node_tree.nodes["Group"].inputs[0].default_value'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment