Configure checkerboard texture using Python


I’m writing a science visualization script in which everything is automated using Python. I’ve succeeded in texturing an mesh object with a node based red/white checkerboard pattern as follows:

# Create new material
parachute_mat =[-1]     # new material is the last one in the list = "ParachuteMat"        # rename

# Add material slot to parachute mesh object (currently active)
# Assign the material to the new material slot (currently active)
bpy.context.object.active_material = parachute_mat

# Create new texture
parachute_text =[-1]     # new texture is the last one in the list = 'ParachuteText'     # rename

# Add texture slot to parachute material
# Enable 'use nodes' on the texture to use default checkerboard pattern (red/white)
parachute_text.use_nodes = True
# Assign the texture to the new texture slot (currently active)
parachute_mat.active_texture = parachute_text

I would like to proceed by changing the colors of the pattern and scaling it, as can be done in the node editor GUI (e.g. at 3:30).

How do I do that using Python? I have trouble finding this in the Blender documentation.

Thank you very much,


“Checker” is the name/identifier string of the node which may vary

so maybe you will have to search and check for its type

for node in parachute_text.node_tree.nodes:
     if node.type=='CHECKER':

That’s excellent, thanks! I had tried to enter and use the node_tree but gave up. Nice to see that even these minute things can be scripted.