0
$\begingroup$

I would like to store my whole node input driver set up of a material in a txt file and load it back any time. How can I access the driver data along with node name and input number?

$\endgroup$
1
$\begingroup$

Look in NodeTree.animation_data

Python console code. Loop thru materials that use nodes and have animation data, if so loop the drivers collection.

enter image description here

In simple example below find the couple of simple drivers including a driver on a value node with expression "frame" (the current frame)

The drivers datapath gives the node name and the index of the socket.

>>> for m in bpy.data.materials:
...     m.name
...     if m.use_nodes and m.node_tree.animation_data:
...         for d in m.node_tree.animation_data.drivers:
...             d.data_path, d.driver.expression
...             
'Material'
('nodes["Value"].outputs[0].default_value', 'frame')
('nodes["Principled BSDF"].inputs[9].default_value', 'frame / 20')

>>> 

Re socket index and name https://blender.stackexchange.com/a/160069/15543

|improve this answer|||||
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.