0
$\begingroup$

I am struggling with this problem. I am on Windows 10 and using Blender 3.5.1.

The set up is quite simple: I've got two noise textures applied to a plane under "Material". I also created a geometry node system whereby the scale values of both textures are controlled from there (i.e., "copy as new driver" transferred to the scales of the textures). See picture attached.

Geometry Nodes Drivers applied to Shader nodes

My problem is the following. When I copy the material to another plane (single-user copy), how can I delete the drivers in "Materials.001" using a python script? I don't want for "Material.001" to still be influenced by the geometry node system. Applying the GN system to "Plane.001" doesn't help either.

I have tried this:

import bpy

source_mat = bpy.data.materials["Material"] # Material of object "Plane"
copied_mat = source_mat.copy()
bpy.context.view_layer.objects.active = D.objects["Plane.001"]
bpy.data.objects["Plane.001"].select_set(True)
activeObject = bpy.context.active_object
activeObject.data.materials.append(copied_mat)

which simply copies the wanted material to "Plane.001" but I am stuck as to how to remove the drivers.

I can see the drivers using:

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

which correctly yields

'Dots Stroke'
'Material'
('nodes["Voronoi Texture"].inputs[2].default_value', 'Input_2')
('nodes["Voronoi Texture.001"].inputs[2].default_value', 'Input_3')

I have seen people removing drivers but it's only on shape keys.

Any help or pointers on this would be appreciated.

$\endgroup$

1 Answer 1

0
$\begingroup$
import bpy

node_tree = bpy.data.materials["Material"].node_tree
node_tree.animation_data_clear()
$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .