Configure checkerboard texture using Python

Hi,

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
bpy.ops.material.new()
parachute_mat = bpy.data.materials[-1]     # new material is the last one in the list
parachute_mat.name = "ParachuteMat"        # rename


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


# Create new texture
bpy.ops.texture.new()
parachute_text = bpy.data.textures[-1]     # new texture is the last one in the list
parachute_text.name = 'ParachuteText'     # rename


# Add texture slot to parachute material
parachute_mat.texture_slots.add()
# 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. http://www.youtube.com/watch?v=9vE3k7dgDyc at 3:30).

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

Thank you very much,
Bart


parachute_text.node_tree.nodes["Checker"].inputs['Color1'].default_value=(0.0,0.0,0.0,0.0)
parachute_text.node_tree.nodes["Checker"].inputs['Color2'].default_value=(0.0,0.0,0.0,0.0)
parachute_text.node_tree.nodes["Checker"].inputs['Size'].default_value=0.0

“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':
         break

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.