Looking for "the script that writes scripts"

I remember a script that could ‘export’ OB:MyMesh to a ‘addMyMesh.py’.

The idea seemed funny – that’s why I tried it in the first place… then noobishly deleted it.

Now, I would like to find it again, because I have a project where it would be a lot more intuitive to execute the generated scripts than to open libraries to append the objects.

I have been searching on Google and in this forum, but I don’t remember how this magic script was called.

Can anybody tell me where I can get this script ?

not sure if this is it but cheeck out http://wiki.blender.org/index.php/Scripts/Manual/Export/mesh_export it is the only thing i can find that has mesh and export in the title. the actual script is here http://svn.navi.cx/misc/trunk/hdr/encoding/opengl/mesh_export.py

try this

http://www.zoo-logique.org/3D.Blender/zip/BPY_exporter_v04.zip

(deleted the double post)

Thank you everybody. JMS, you are right, it’s JB Perrin’s script (I eventually found it :http://www.zoo-logique.org/3D.Blender/index.php3?zoo=dld&rep=zip), I will try this version since the most recent one that I have found seems to be broken.

rdo3, I will try your script too.

Since I wanted to add some primitives to work faster on a project, I have made this one :

#!BPY
"""
Name: 'Script Generator Alpha'
Blender: 248
Group: 'Object'
Tip: 'Convert mesh object to python script'
"""

#Santa-licensed ! Merry Christmas to benevolent Blenderheads !

import bpy
import Blender
from Blender import *
import Blender
import os

SAVE=True #Set to False if you don't want to save the new script
NL=os.linesep

sce=bpy.data.scenes.active
ob_act=sce.objects.active
nom_obj=ob_act.name

txt=Text.New(nom_obj+".py")

#WRITES THE BLENDER STANDARD HEADER TO SCRIPT
HEADER = "#!BPY"+NL\
+"\""*3+NL\
+"Name: '"+nom_obj+"'"+NL\
+"Blender : 248"+NL\
+"Group: 'AddMesh'"+NL\
+"Tooltip : add a new '"+nom_obj+"' mesh"+NL\
+"\""*3+2*NL\
+"import Blender"+NL\
+"import bpy"+NL\
+"from Blender import *"+2*NL
txt.write(HEADER)

#WRITES THE DATA INITIALIZATION TO SCRIPT
txt.write('scn=bpy.data.scenes.active'+NL)
txt.write("me=bpy.data.meshes.new('"+nom_obj+"')"+NL)
txt.write("ob=scn.objects.new(me,me.name)"+NL*2)

#COPIES THE MESH DATA TO NEW SCRIPT (ONLY FACES & VERTICES)
me=ob_act.getData(mesh=True)

#List of vertices
txt.write('vert_list = ['+NL)
for i in me.verts:
    txt.write("	"+str(list(i.co))+","+NL)
txt.write("	]"+2*NL)

#list of faces
facesList=[]
for i in me.faces:
    j=[k.index for k in i]
    facesList.append(j)

txt.write('faces_list = ['+NL)        
for i in facesList:
    txt.write("	"+str(i)+","+NL)
txt.write("	]"+2*NL)

#commands
txt.write("me.verts.extend(vert_list)"+NL)
txt.write("me.faces.extend(faces_list)"+NL)

#SAVES NEW SCRIPT TO SCRIPTS DIRECTORY
if SAVE :
    scr_directory=Get("scriptsdir")
    scr_name=scr_directory+os.sep+txt.name

    content=txt.asLines()
    f=open(scr_name,'w')
    for i in content:
        f.write(i+NL)
    f.close()

I am only learning Python, so the generated script only takes into account vertices and faces in the original mesh. I’ll be glad if anybody wants to improve it. If anyone wants to use it, it’s Santa-licenced (free toys for all nice children !), as stated in the code.

I have posted the same script here : http://blenderartists.org/forum/showthread.php?p=1284793

Actually the BPY Exporter script (version 1.1) is located here : http://pagesperso-orange.fr/jb.perin/Archive/BPY_exporter_v11.zip. I still haven’t managed to make it work.