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!

  • 1
    $\begingroup$ Hi @andesign , please check the checkmark left to lemon's answer if it helped you - and i think it did. Thanks. $\endgroup$
    – Chris
    Mar 19, 2022 at 3:18

1 Answer 1


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 )

You must log in to answer this question.

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