Export Mesh Data to .py File - Not Working

Hello everyone,

I’m attempting to write script/addon to convert mesh data into a python (.py) file. This is probably really basic and I am watching Patrick Boelens CGCookie tutorial on it. My issue is, it seems to be in working order, I am at the same point in the video as he first attempts to run it as an add-on. His works, but mine does not. As far as I can tell, I’ve written mine about the same as his, with a few minor changes:

import bpy

class exportToPY(bpy.types.Operator):
    bl_idname = "export.export_to_py"
    bl_label = "Export to PY"
    def execute(self, context):
        obverts = bpy.context.active_object.data.verticies
        verts = []
        for vertex in obverts:
            print (verts)
def register():

def unregister():

What exactly am I missing/doing wrong?

I’ll probably kick myself when I find out for making such a stupid mistake, but it’ll be worth it to get this working, so I can use it on my future projects.

Yeah, I could probably go copy and paste one from somewhere, but I’d rather have someone more wise teach me, so I can learn from my mistakes and move forward.

Is it giving you an error? At first glance, the ‘return’ seems to be indented wrong, but it would help to see an error.

Yes, I get an error. I’m not sure what it means though.


And, you were correct about the indentation, but unfortunately that didn’t resolve the issue.

looks like script is out of date? there’s clearly no call to menu_func() in line 34…

Well, that would make sense. The tutorial I was following was around the 2.5 era. I didn’t think that the API had changed that much since then. I’ll look into the new API and see what I can dig up. It’s kind of difficult with the Blender.org site update though.

Thank you for your help!

Would I need to add a call to menu_func()?

I’m really new to the scripting side of Blender. Only a few days in. So, I’m sorry if I’m misunderstanding a lot.

oh, i didn’t mean to refer to API changes. It mean “outdated” literally, it looks like blender runs another version of that script which has a call to menu_func() in line 34. Maybe it uses some cached file? You should restart blender and try again.

Alright, I’ll give that a try. Thank you for clearing that up!