Camera tracking: libmv distortion API now also uses camera intrinsics
[blender-staging.git] / release / scripts / templates_py / operator_file_export.py
1 import bpy
2
3
4 def write_some_data(context, filepath, use_some_setting):
5     print("running write_some_data...")
6     f = open(filepath, 'w', encoding='utf-8')
7     f.write("Hello World %s" % use_some_setting)
8     f.close()
9
10     return {'FINISHED'}
11
12
13 # ExportHelper is a helper class, defines filename and
14 # invoke() function which calls the file selector.
15 from bpy_extras.io_utils import ExportHelper
16 from bpy.props import StringProperty, BoolProperty, EnumProperty
17 from bpy.types import Operator
18
19
20 class ExportSomeData(Operator, ExportHelper):
21     """This appears in the tooltip of the operator and in the generated docs"""
22     bl_idname = "export_test.some_data"  # important since its how bpy.ops.import_test.some_data is constructed
23     bl_label = "Export Some Data"
24
25     # ExportHelper mixin class uses this
26     filename_ext = ".txt"
27
28     filter_glob = StringProperty(
29             default="*.txt",
30             options={'HIDDEN'},
31             )
32
33     # List of operator properties, the attributes will be assigned
34     # to the class instance from the operator settings before calling.
35     use_setting = BoolProperty(
36             name="Example Boolean",
37             description="Example Tooltip",
38             default=True,
39             )
40
41     type = EnumProperty(
42             name="Example Enum",
43             description="Choose between two items",
44             items=(('OPT_A', "First Option", "Description one"),
45                    ('OPT_B', "Second Option", "Description two")),
46             default='OPT_A',
47             )
48
49     def execute(self, context):
50         return write_some_data(context, self.filepath, self.use_setting)
51
52
53 # Only needed if you want to add into a dynamic menu
54 def menu_func_export(self, context):
55     self.layout.operator(ExportSomeData.bl_idname, text="Text Export Operator")
56
57
58 def register():
59     bpy.utils.register_class(ExportSomeData)
60     bpy.types.INFO_MT_file_export.append(menu_func_export)
61
62
63 def unregister():
64     bpy.utils.unregister_class(ExportSomeData)
65     bpy.types.INFO_MT_file_export.remove(menu_func_export)
66
67
68 if __name__ == "__main__":
69     register()
70
71     # test call
72     bpy.ops.export_test.some_data('INVOKE_DEFAULT')