Material exporter

it is possible to export a mesh to a python script.
similarly is it possible to export the materials setting to a python script as well?

Why would you want to export a mesh to a python script? I’m not sure I understand the question :S

It is possible to export a mesh to an .obj file so that you can later restore it or create new instances ( imagine you want a template - you just export your model to one .obj file then create that object from that file as many times as you want)

It is also possible to store this info in lists and then copy-paste this lists into a python script then use that info when you want for the same purpose as the .obj file - is that what you want? That might be useful if your object is always the same, otherwise the .obj aproach is more flexible

Why would you want to export a mesh to a python script? I’m not sure I understand the question :S
theirs a lot of trivial reasons for me doing this.
it deals with kids ,i teach kids
so my method of teaching is from simple>>to advance so i try and do the best i can to keep the attention of young kids.

,i already know how to export a mesh to a mesh.py, no problems ,simply appending verts ,faces as an array and it works perfectly .
so heres the result i just created a primitives window
http://blenderartists.org/forum/showthread.php?t=158136

what i want to do now is try and export the material settings such as r,g,b,ior,texture location to a python script if possible

than later on apply the settings exported by clicking on an object and applying the python script material settings
eg i export the settings for gold >>gold.py ,than i get an object, eg cube ,apply gold.py to cube

http://www.blender.org/documentation/248PythonDoc/ - use this page to create the material from the data

http://www.blender.org/documentation/248PythonDoc/Material.Material-class.html --> this page is to get the data from the material

import Blender 
print Blender.Material.Get() # list of materials in use or deleted!
material = Blender.Material.Get("matname") # make sure the matname is valid and not just a deleted material
 
specs = dir(material) # remove what you don't want from the list # in the list should exist only the get... attributes 
filtered_specs = [spec for spec in specs if spec.startswith("get")] # remove what you don't want from the list # in the list should exist only the get... attributes 
print filtered_specs 
reconstruct_list = ["set"+spec[3:] for spec in filtered_specs] 
print reconstruct_list 
 
def mat_specs(mat,filtered_specs):  #doesn't work :( eiter get it working or do it by hand
    list = [] 
    for i in filtered_specs: 
        stat = i+"()" 
        print stat 
        list.append(mat.stat) 
    return list 
 
print mat_specs(material,filtered_specs)