4 def write_some_data(context, filepath, use_some_setting):
5 print("running write_some_data...")
6 f = open(filepath, 'w')
7 f.write("Hello World %s" % use_some_setting)
13 # ExportHelper is a helper class, defines filename and
14 # invoke() function which calls the file selector.
15 from io_utils import ExportHelper
17 from bpy.props import *
20 class ExportSomeData(bpy.types.Operator, ExportHelper):
21 '''This appiers in the tooltip of the operator and in the generated docs.'''
22 bl_idname = "export.some_data" # this is important since its how bpy.ops.export.some_data is constructed
23 bl_label = "Export Some Data"
25 # ExportHelper mixin class uses this
28 filter_glob = StringProperty(default="*.txt", options={'HIDDEN'})
30 # List of operator properties, the attributes will be assigned
31 # to the class instance from the operator settings before calling.
32 use_setting = BoolProperty(name="Example Boolean", description="Example Tooltip", default=True)
34 type = bpy.props.EnumProperty(items=(('OPT_A', "First Option", "Description one"), ('OPT_B', "Second Option", "Description two.")),
36 description="Choose between two items",
40 def poll(cls, context):
41 return context.active_object != None
43 def execute(self, context):
44 return write_some_data(context, self.filepath, self.use_setting)
47 # Only needed if you want to add into a dynamic menu
48 def menu_func_export(self, context):
49 self.layout.operator(ExportSomeData.bl_idname, text="Text Export Operator")
53 bpy.utils.register_class(ExportSomeData)
54 bpy.types.INFO_MT_file_export.append(menu_func_export)
58 bpy.utils.unregister_class(ExportSomeData)
59 bpy.types.INFO_MT_file_export.remove(menu_func_export)
62 if __name__ == "__main__":
66 bpy.ops.export.some_data('INVOKE_DEFAULT')