2
$\begingroup$

I am writing an addon and I need to delete an image texture node from the active material. I know that the python for deleting the node from the editor is bpy.ops.node.delete(), but I don't know how to make this work from the script. I might sound dumb asking this, but I am a beginner to writing addons.

Thanks in advance!

$\endgroup$
2
$\begingroup$

You can do something like this:

import bpy

#Get the material you want (replace the name below)
mat = bpy.data.materials['Material']

#Get the node in its node tree (replace the name below)
node_to_delete =  mat.node_tree.nodes['Principled BSDF']

#Remove it
mat.node_tree.nodes.remove( node_to_delete )
$\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.