I got an animation with blinking lights, animated with an Emission Node and Transparent Node connected to a Mix Shader. The Mix Shader is animated, so the lights are going on and off by setting the Factor to 0 or 1.

More than 40 materials are already animated, but now I want to adjust the strength of the emission. I don't want to manually edit each material, adjusting the Emmission node's Strength. Is there a way to handle this in a batch?

If I knew earlier than I would work with Node Groups, but I didn't. I'm not good at python, but I think it's possible to create a sort of find and replace script in the context of selected materials.


1 Answer 1


Good news - that's relatively easy:

import bpy 

sel = bpy.context.selected_objects

for obj in sel:
        for slots in obj.material_slots:
            for nodes in slots.material.node_tree.nodes:
                if nodes.type == 'EMISSION':
                    nodes.inputs[0].default_value = (1,0,0,1) # change RGBA if needd
                    nodes.inputs[1].default_value = 100 # change strength
                    #print(nodes.label) # for testing
        print('Something wrong with ' + obj.name) # Maybe an object not capable of having materials or empty slot

You can copy/paste this into a new text block int the Text Editor and hit Run Script with the objects that have the materials you want to modify selected.


You must log in to answer this question.

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