I got this error once yesterday but not since I finalized the function. Now I'm making more of the same buttons for similar but different functions, and now the first one is throwing this:
experiment.blend/bake_script", line 71, in execute
IndexError: tuple index out of range
There isn't any tuple in this code, as far as I can tell.
for mat in obj.data.materials:
mat.use_nodes = True #Here it is assumed that the materials have been created with nodes, otherwise it would not be possible to assign a node for the Bake, so this step is a bit useless
bake_one.is_active_output = True
mat.node_tree.links.new(skin_comp.outputs[0], bake_one.inputs[0])
linkToDelete = baked_BSDF.inputs[0].links[0]
mat.node_tree.links.remove(linkToDelete)
bump_main.mute = True
texture_node = diffuse
texture_node.select = True
nodes.active = texture_node
texture_node.image = imgbake #Assign the image to the node
The line that's throwing the error is linkToDelete = baked_BSDF.inputs[0].links[0]
There are two mysteries here:
1: Why is it throwing this error today, when it wasn't yesterday?
2: Why does it think it's getting a tuple in this?
Edit: It's this connection in particular, but I'm having the same issue with the new button I'm making too.
It occurred to me that maybe the nodes are listing connections as tuples, but then 0,0 should be within that list...
baked_BSDF
doesn't have any input which seems unlikely, or its first input isn't linked to any other node, which is possible. Are you sure you're in a scenario where this node has a link to another node ? $\endgroup$if node.inputs[0].links:
for example. It will evaluate toFalse
iflinks
is empty (ie length 0, no link) $\endgroup$