Need help w/ old script: Change diffuse shader to emission shader without affecting shader color

Hi, I found the exact thing I need in a Stack Exchange question.

Problem is it’s old and I think some of the terms have changed as it’s not running. I tried changing



if obj.select_set:


if node.type=='BSDF_DIFFUSE':


if node.type=='Principled BSDF':

but these changes didn’t do anything. Would it be possible to get any help on this?

In the console, entering the first line and hitting the tab button on the keyboard:

>>> ob.select_
>>> ob.select_get(
Test if the object is selected. The selection state is per view layer
>>> ob.select_get()

Note that the ob.select_get() returned a boolean, so my bet is that is what needs to take the place of the “if obj.select_set:” statement.

As for the node issue, I am not so knowledgeable on nodes, the code runs fine in the text editor after modifying the if statement, so I am not sure why the node type would not be changing. One thing you could try is manually changing the node, and watching in the info window what code it uses to do the switch, if it uses different code, that is likely the issue, if it does not, there is a deeper issue, also, Blender is extremely picky about what it can do based on the MODE it is in, so it may just be that the mode needs to be different.

1 Like

Awesome thank you. Yes “select_get()” was the answer. And the node.type==‘BSDF_PRINCIPLED’

1 Like