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