Add menu in existing submenu

Hi All,

I wanted to create very simple export script just to save some geometry and perhaps a basic texture.
I quickly found a nice tutorial about it on wiki (I believe I can’t put link since it’s my first post)
It covers how to get data of objects on the scene along with basic console usage and how to write in a file in very short and easy way.
It all looked very simple and intuitive until I tried to run whole script. It seems that this code is deprecated.
This is this the code:

#!BPY"""
Name: 'Wikibooks'
Blender: 259
Group: 'Export'
Tooltip: 'Wikibooks sample exporter'
"""
import Blender
import bpy

def write(filename):
    out = open(filename, "w")
    sce= bpy.data.scenes.active
    for ob in sce.objects:
        out.write(ob.type + ": " + ob.name + "
")
    out.close()
 Blender.Window.FileSelector(write, "Export")

It says

This page is an update of a great tutorial originally built for blender 2.44.

I got blender 2.63.

I’ve tried other examples but after a while I still can’t find the solution.
Last thing I’ve tried is this:

bl_info = {    "name": "Skrypt test",
    "description": "Single line explaining what this script exactly does.",
    "author": "Audionysos",
    "version": (1, 0),
    "blender": (2, 63, 0),
    "location": "View3D > Add > Mesh",
    "warning": "", # used for warning icon and text in addons panel
    "category": "Add Mesh"}


	
import bpy


class customExporter(bpy.types.Menu):
	bl_label = "Custom Exporter"
	bl_idname = "view3D.custom_exporter"
	
	def draw(self, context):
		layout = self.layout
		layout.operator("mesh.primitive_cube_add")
		##layout.operator("mesh.primitive_cube_add")


def draw2(self, context):
		layout = self.layout
		layout.operator("mesh.primitive_cube_add")
		##layout.operator("mesh.primitive_cube_add")
		
def register():
	bpy.utils.register_class(customExporter)
	bpy.types.INFO_MT_file.append(draw2);
#	bpy.ops.wm.call_menu(name=customExporter.bl_idname)
	
def unregister():
	bpy.utils.unregister_class(customMenu)
	
if __name__ == "__main__":
	register()

Is there a direct type of export submenu? - maybe something like this:
bpy.types.EXPORT.append(draw2)
or how i can acces it?

I first was pleasantly suprised that I can check api documentation even at runtime but it’s nothing helpful if
method description is just a name

prop_menu_enum(data, property, text=“”, text_ctxt=“”, translate=True, icon=‘NONE’)prop_menu_enum

I’m also not sure with couple things.
Is bpy.types a list of all classes registered by bpy.utils.register_class?

In above example code, can i use draw function instead of draw2?
I understand that draw is local function of customExporter so i need to instantiate it before pass it to append()
but since i use register_class() i understand that at some point instance of customExporter will be constructed by bpy, so “self” won’t always point to the same object instance. How can i ensure that my addon executed form different places in blender share the same data?

In turtorial i mentioned there was line like
bpy.data.meshes[‘Cube’].faces
but console says that my cube don’t have faces. Why is that? Did mesh structure changed since then?
bpy.data.meshes[‘Cube’].vertices - works ok.

Thanks for Your time. I’ll very grateful if you can help me.

bpy.types.INFO_MT_file_export.append(menu_func_export)

See the Operator File Export template

Thanks, I reviewed types but miss that.
Now everything works fine :slight_smile:
I also found updated example on how to write export script on Bruce Sutherland blog.
About faces, now you can access them through mesh.polygons or mesh.tessfaces.

I’m also interested on how to place operator at custom position in menu, so if you know something about it, please give me an idea.

Thanks again :slight_smile:

I understand, I mean I don’t understand why such a thing is not supported but understand that this is not worth spending my time on it now. Although such open-heart surgery is very charming I will probably set a shortcut for my operator :slight_smile: