# ----------------------------------------------------------------------------- # # Export template - a simple script showing boiler plate for an export script # # Put this script in the [addons] folder. Under OS-X, you need to right click # on the blender executable and select 'show package content' to access scripts # (blender/Contents/MacOS/scripts/addons) # # IMPORTANT: to enable a script, go to [user preferences] and select the add-ons tab. # Find the script and check/uncheck the box on the right to enable/disable. # If you can't check the box to enable, likely there is a syntax error. # Enable/disable is also convenient while testing, you can uncheck-check to reload # the script. # # target: Blender 2.59 # SOURCE: http://www.oogtech.org/content/ # CREATED BY T.E.A de SOUZA # LICENSE: PUBLIC DOMAIN # # ----------------------------------------------------------------------------- bl_info = { "name": "export template 1.0", "author": "T.E.A de Souza", "version": (0, 1, 0), "blender": (2, 5, 9), "api": 37702, "location": "File > Export > Export Template", "description": "A template to write your own export script", "warning": "", "wiki_url": "", "tracker_url": "", "category": "Import-Export"} import os import bpy import io from bpy.props import StringProperty, EnumProperty, BoolProperty class TestExporter(bpy.types.Operator): bl_idname = "export.test" bl_label = "Export Template" filepath = StringProperty(subtype='FILE_PATH') # This is called first. It will open the file selector; after the user # selected a file, execute(self,context) is called. def invoke(self, context, event): if not self.filepath: self.filepath = bpy.path.ensure_ext(bpy.data.filepath, ".txt") WindowManager = context.window_manager WindowManager.fileselect_add(self) return {"RUNNING_MODAL"} # Called by the file selector def execute(self, context): filepath = self.filepath self.save(context, **self.properties) return {"FINISHED"} # Save the file def save(self, context, filepath=""): if os.path.splitext(filepath)[1] == '': filepath += ".txt" f = io.open(filepath, mode="wt", newline="\n", encoding="utf_8") f.write("just a test\n") f.close() def menu_func(self, context): self.layout.operator(TestExporter.bl_idname, text="Export Template (for test)") def register(): bpy.utils.register_module(__name__) bpy.types.INFO_MT_file_export.append(menu_func) def unregister(): bpy.utils.unregister_module(__name__) bpy.types.INFO_MT_file_export.remove(menu_func) if __name__ == "__main__": register()