Simple .OBJ Material to Cycles Material Converter Script


I’m trying to write a script wich converts the non-node mat´s of the imported mesh into cycles node mat´s with assigned image textures. These images are lying in the same folder as the .blend file does and every material is named like the image wich behaves to it. So the code thought about should do this, but I dont know how to wirte it in phyton:

import bpy

for all materials:
   material use nodes
   material color = imagetexture(Path='...', name=''.png)

I hope you understand what I meant.

couple things,

the line for all materials needs to be something more like
for a in

that way it sets each variable to a
next you will need to do
a.use_nodes = True

and you cant just set material colour, you will first have to find what texture is hooked up to the object in BI, then you will need to create a image texture node in the node editor (which you can do with python) and then you will need to connect the image texture node colour output to the diffuse input.

If you do a search in the Code forum you will discover that there is a script that converts Blender Internal materials to Cycles nodes.