nuclear@33: # Goat3D Blender >2.5 exporter nuclear@33: import bpy; nuclear@33: from bpy_extras.io_utils import ExportHelper nuclear@36: import ctypes nuclear@36: from ctypes import * nuclear@36: from ctypes.util import find_library nuclear@36: import os nuclear@33: nuclear@33: bl_info = { nuclear@33: "name": "Goat3D scene", nuclear@33: "author": "John Tsiombikas", nuclear@33: "version": (0, 1), nuclear@33: "location": "File > Import-Export", nuclear@33: "description": "Mutant Stargoat, Goat3D scene file format: http://code.google.com/p/goat3d/", nuclear@33: "category": "Import-Export" nuclear@33: } nuclear@33: nuclear@33: class ExportGoat3D(bpy.types.Operator, ExportHelper): nuclear@37: bl_idname = "export_scene.goat3d" nuclear@37: bl_label = "Export Goat3D Scene" nuclear@36: bl_options = {'PRESET'} nuclear@36: filename_ext = ".goatsce" nuclear@37: filter_glob = bpy.props.StringProperty(default="*.goatsce", options={'HIDDEN'}) nuclear@33: nuclear@33: @classmethod nuclear@33: def poll(cls, ctx): nuclear@33: return ctx.object is not None nuclear@33: nuclear@36: def execute(self, ctx): nuclear@36: libname = find_library("goat3d") nuclear@36: if not libname: nuclear@36: self.report({'ERROR'}, "Could not find the goat3d library! make sure it's installed.") nuclear@36: return {'CANCELLED'} nuclear@37: nuclear@36: libgoat = CDLL(libname) nuclear@36: if not libgoat: nuclear@36: self.report({'ERROR'}, "Could not open goat3d library!") nuclear@36: return {'CANCELLED'} nuclear@36: nuclear@36: goat3d_create = libgoat.goat3d_create nuclear@36: goat3d_create.argtypes = None nuclear@36: goat3d_create.restype = c_void_p nuclear@36: nuclear@36: goat3d_free = libgoat.goat3d_free nuclear@36: goat3d_free.argtypes = [c_void_p] nuclear@36: goat3d_free.restype = None nuclear@36: nuclear@37: goat3d_save = libgoat.goat3d_save nuclear@37: goat3d_save.argtypes = [c_void_p, c_char_p] nuclear@36: nuclear@37: print("Exporting goat3d file: " + self.filepath) nuclear@36: nuclear@36: goat = goat3d_create() nuclear@36: if not goat: nuclear@36: self.report({'ERROR'}, "Failed to create goat3d object") nuclear@36: return {'CANCELLED'} nuclear@36: nuclear@37: print(type(goat)) nuclear@37: print(type(self.filepath)) nuclear@37: goat3d_save(goat, c_char_p(self.filepath)) nuclear@36: goat3d_free(goat) nuclear@33: return {'FINISHED'} nuclear@33: nuclear@33: def menu_func(self, ctx): nuclear@33: self.layout.operator_context = 'INVOKE_DEFAULT' nuclear@36: self.layout.operator(ExportGoat3D.bl_idname, text="Goat3D scene export (.goatsce)") nuclear@33: nuclear@33: def register(): nuclear@33: bpy.utils.register_module(__name__) nuclear@33: bpy.types.INFO_MT_file_export.append(menu_func) nuclear@33: nuclear@33: def unregister(): nuclear@33: bpy.utils.unregister_module(__name__) nuclear@33: bpy.types.INFO_MT_file_export.remove(menu_func) nuclear@33: nuclear@33: if __name__ == "__main__": nuclear@33: register()