I am a newbie to scripting and coding in general so this might be a stupid question. I am trying to design an automation script for SimpleBakes addon to automatically select the necessary PBR bake passes for an object based on the properties of Principled BSDF as it iterates through each material of the object.
- Turning on metallic pass if the metalic value of Principled BSDF is anything other than 0.
- Turning on Transparency pass if the transmission value of Principled BSDF is anything other than 0.
- turning on the Emission pass if the Emission color of Principled BSDF is anything other than black (0, 0, 0, 1) [[ This is where my issue arises]]
- turning on the Alpha pass if the alpha value of Principled BSDF is anything other than 1.
here is my script in it’s entirety:
import bpy m=0 bpy.context.scene.selected_col = True bpy.context.scene.selected_rough = True bpy.context.scene.selected_normal = True bpy.context.scene.selected_metal = False bpy.context.scene.selected_trans = False bpy.context.scene.selected_emission = False bpy.context.scene.selected_alpha = False for m in bpy.context.object.material_slots: if m.material.node_tree.nodes["Principled BSDF"].inputs.default_value != 0: bpy.context.scene.selected_metal = True if m.material.node_tree.nodes["Principled BSDF"].inputs.default_value != 0: bpy.context.scene.selected_trans = True if m.material.node_tree.nodes["Principled BSDF"].inputs.default_value != [0, 0, 0, 1]: bpy.context.scene.selected_emission = True if m.material.node_tree.nodes["Principled BSDF"].inputs.default_value != 1: bpy.context.scene.selected_alpha = True
As you can see in the script, all these passes should be False by default at the beginning of the script. The issue I am facing is the emission pass keeps turning on for each and every object regardless of whether it has an emissive material. it is as if all the objects have their emission colors set to values other than black which is very much not the case.
Why is this issue arising, have I mistyped the syntax for activating on colors other than black? Any help regarding this would be greatly appreciated.