fix for blender-2.63
[io_import_off.git] / io_import_off.py
index 1ca085404af444310c4a0e0d93fee93e43aabf30..6a608ed8cbbbfe95da7ebaf6336d3e26f945c40f 100644 (file)
@@ -3,25 +3,19 @@
 # Import DEC Object File Format (*.off)\r
 \r
 \r
 # Import DEC Object File Format (*.off)\r
 \r
 \r
-bl_addon_info = {\r
+bl_info = {\r
                "name": "Import DEC Object File Format (.off)",\r
                "name": "Import DEC Object File Format (.off)",\r
-               "author": "Stefan Huber (shuber)",\r
-               "version": (0,7),\r
-               "blender": (2, 5, 3),\r
+               "author": "Stefan Huber (shuber2@gmail.com)",\r
+               "version": (0,0),\r
+               "blender": (2, 5, 57),\r
                "api": 31667,\r
                "location": "File > Import > Import DEC Object File Format (.off)",\r
                "description": "Import DEC Object File Format (.off) files",\r
                "warning": "",\r
                "api": 31667,\r
                "location": "File > Import > Import DEC Object File Format (.off)",\r
                "description": "Import DEC Object File Format (.off) files",\r
                "warning": "",\r
-               "category": "Import/Export"\r
+               "category": "Import-Export"\r
                }\r
 \r
                }\r
 \r
-\r
-\r
-__author__ = "Stefan Huber"\r
-#__url__ = ("blender", "blenderartists.org", "Author's homepage, http://www.redrival.com/scorpius")\r
-#__version__ = "Part of IOSuite 0.5"\r
-\r
-__bpydoc__ = """\\r
+"""\r
 This script imports DEC Object File Format files to Blender.\r
 \r
 The DEC (Digital Equipment Corporation) OFF format is very old and\r
 This script imports DEC Object File Format files to Blender.\r
 \r
 The DEC (Digital Equipment Corporation) OFF format is very old and\r
@@ -41,6 +35,11 @@ Notes:<br>
        New Mesh module now used. - Cam\r
 """\r
 \r
        New Mesh module now used. - Cam\r
 """\r
 \r
+__version__ = '.'.join([str(s) for s in bl_info['version']])\r
+\r
+\r
+\r
+\r
 import bpy\r
 from bpy.props import *\r
 \r
 import bpy\r
 from bpy.props import *\r
 \r
@@ -85,7 +84,7 @@ def unpack_faces(faces):
                        # Rotate triangle, such that last index is not zero\r
                        if tri[2] == 0:\r
                                tri = [ tri[2], tri[0], tri[1] ]\r
                        # Rotate triangle, such that last index is not zero\r
                        if tri[2] == 0:\r
                                tri = [ tri[2], tri[0], tri[1] ]\r
-                       \r
+\r
                        l.extend(tri)\r
                        l.extend([0])\r
 \r
                        l.extend(tri)\r
                        l.extend([0])\r
 \r
@@ -95,7 +94,7 @@ def unpack_faces(faces):
 def importFile(filepath, context):\r
 \r
        # List of vertices, a vertex is a 3-tuple (x,y,z)\r
 def importFile(filepath, context):\r
 \r
        # List of vertices, a vertex is a 3-tuple (x,y,z)\r
-       vertices = [] \r
+       vertices = []\r
        # List of faces, a face is a list of indices within vertices\r
        faces = []\r
 \r
        # List of faces, a face is a list of indices within vertices\r
        faces = []\r
 \r
@@ -136,7 +135,7 @@ def importFile(filepath, context):
                # Get all faces\r
                for n in range(numFaces):\r
                        line = getNextLine(f).split()\r
                # Get all faces\r
                for n in range(numFaces):\r
                        line = getNextLine(f).split()\r
-                       \r
+\r
                        # Get number of vertices\r
                        lenFace = int(line[0])\r
                        line = line[1:]\r
                        # Get number of vertices\r
                        lenFace = int(line[0])\r
                        line = line[1:]\r
@@ -157,9 +156,9 @@ def importFile(filepath, context):
 \r
                # Add given number of vertices and faces\r
                me.vertices.add( len(vertexdata)//3 )\r
 \r
                # Add given number of vertices and faces\r
                me.vertices.add( len(vertexdata)//3 )\r
-               me.faces.add( len(facedata)//4 )\r
+               me.tessfaces.add( len(facedata)//4 )\r
                me.vertices.foreach_set("co", vertexdata)\r
                me.vertices.foreach_set("co", vertexdata)\r
-               me.faces.foreach_set("vertices_raw", facedata)\r
+               me.tessfaces.foreach_set("vertices_raw", facedata)\r
                me.update()\r
 \r
                ob = bpy.data.objects.new("Mesh", me)\r
                me.update()\r
 \r
                ob = bpy.data.objects.new("Mesh", me)\r
@@ -173,22 +172,23 @@ def importFile(filepath, context):
                print("Error reading .off file")\r
                print(e)\r
                return False\r
                print("Error reading .off file")\r
                print(e)\r
                return False\r
-       \r
 \r
 \r
 \r
 \r
-class ImportOffFile(bpy.types.Operator):\r
+\r
+class IMPORT_OT_dec_off(bpy.types.Operator):\r
        '''Import DEC object file format (.off) files as specified by\r
 http://shape.cs.princeton.edu/benchmark/documentation/off_format.html'''\r
 \r
        '''Import DEC object file format (.off) files as specified by\r
 http://shape.cs.princeton.edu/benchmark/documentation/off_format.html'''\r
 \r
-       bl_idname = "import.off_files"\r
-       bl_label = "Import DEC Object File Format (.off)"\r
+       bl_idname = "import_scene.dec_off"\r
+       bl_label = "Import DEC off"\r
        bl_description = "Imports DEC object file format (.off)"\r
        bl_options = {'REGISTER'}\r
 \r
        filepath = StringProperty(name="File Path",\r
                        description="Filepath used for importing the file",\r
                        maxlen=1024,\r
        bl_description = "Imports DEC object file format (.off)"\r
        bl_options = {'REGISTER'}\r
 \r
        filepath = StringProperty(name="File Path",\r
                        description="Filepath used for importing the file",\r
                        maxlen=1024,\r
-                       default="" )\r
+                       default=""\r
+                       )\r
 \r
        extEnum = [\r
                        ('*', 'All image formats', 'Import all know image (or movie) formats.'),\r
 \r
        extEnum = [\r
                        ('*', 'All image formats', 'Import all know image (or movie) formats.'),\r
@@ -216,13 +216,16 @@ http://shape.cs.princeton.edu/benchmark/documentation/off_format.html'''
 \r
 # Registering / Unregister\r
 def menu_func(self, context):\r
 \r
 # Registering / Unregister\r
 def menu_func(self, context):\r
-       self.layout.operator(ImportOffFile.bl_idname, \\r
-                       text="DEC Object File Format (.off)", icon='PLUGIN')\r
+       self.layout.operator(IMPORT_OT_dec_off.bl_idname,\r
+                       text="DEC Object File Format (.off)",\r
+                       icon='PLUGIN' )\r
 \r
 def register():\r
 \r
 def register():\r
+       bpy.utils.register_module(__name__)\r
        bpy.types.INFO_MT_file_import.append(menu_func)\r
 \r
 def unregister():\r
        bpy.types.INFO_MT_file_import.append(menu_func)\r
 \r
 def unregister():\r
+       bpy.utils.unregister_module(__name__)\r
        bpy.types.INFO_MT_file_import.remove(menu_func)\r
 \r
 \r
        bpy.types.INFO_MT_file_import.remove(menu_func)\r
 \r
 \r