0
$\begingroup$

Let me elaborate, so, there's over 200-500 textures and I need to make it so that the texture that is connected to "Base Color" is removed from all of them, would there be any way to do it?

Is there any way to do it?

Adding onto this, all of the textures have different names.

$\endgroup$
1
  • 1
    $\begingroup$ of course - with python it should be very easy. But what do you want to remove? the whole material? or just the image texture? Please describe as detailed as possible. thx. $\endgroup$
    – Chris
    Commented Feb 11, 2023 at 13:20

1 Answer 1

1
$\begingroup$
import bpy

for material in bpy.data.materials:
    if not material.use_nodes:
        continue
    for node in material.node_tree.nodes:
        if node.type == 'BSDF_PRINCIPLED':
            if node.inputs['Base Color'].is_linked:
               
                # remove
                material.node_tree.nodes.remove(node.inputs['Base Color'].links[0].from_node)
               
                # disconnect
                # material.node_tree.links.remove(node.inputs['Base Color'].links[0])
                
$\endgroup$
1
  • $\begingroup$ Note this will remove ALL nodes that are linked to BSDF color input $\endgroup$
    – Gorgious
    Commented Feb 12, 2023 at 11:01

You must log in to answer this question.

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