File indexing completed on 2025-01-19 03:59:55
0001 from bpy_extras.io_utils import ExportHelper 0002 from bpy.props import StringProperty, BoolProperty, EnumProperty, FloatProperty 0003 from bpy.types import Operator 0004 0005 from . import blender_export 0006 0007 0008 class LottieExporterBase(Operator): 0009 def execute(self, context): 0010 animation = blender_export.context_to_tgs(context) 0011 self._export_animation(animation) 0012 return {'FINISHED'} 0013 0014 def _export_animation(self, animation): 0015 raise NotImplementedError() 0016 0017 0018 class LottieExporterTgs(LottieExporterBase, ExportHelper): 0019 """ 0020 Export Telegram animated sticker 0021 """ 0022 format = "tgs" 0023 bl_label = "Telegram Sticker (*.tgs)" 0024 bl_idname = "lottie.export_" + format 0025 0026 filename_ext = "." + format 0027 0028 filter_glob: StringProperty( 0029 default="*." + format, 0030 options={'HIDDEN'}, 0031 maxlen=255, 0032 ) 0033 0034 def _export_animation(self, animation): 0035 blender_export.lottie.exporters.export_tgs(animation, self.filepath) 0036 0037 0038 class LottieExporterLottie(LottieExporterBase, ExportHelper): 0039 """ 0040 Export Lottie JSON 0041 """ 0042 format = "json" 0043 bl_label = "Lottie (.json)" 0044 bl_idname = "lottie.export_" + format 0045 0046 filename_ext = "." + format 0047 0048 filter_glob: StringProperty( 0049 default="*." + format, 0050 options={'HIDDEN'}, 0051 maxlen=255, 0052 ) 0053 0054 pretty: BoolProperty( 0055 name="Pretty", 0056 description="Pretty print the resulting JSON", 0057 default=False, 0058 ) 0059 0060 def _export_animation(self, animation): 0061 blender_export.lottie.exporters.export_lottie(animation, self.filepath, self.pretty) 0062 0063 0064 class LottieExporterHtml(LottieExporterBase, ExportHelper): 0065 """ 0066 Export HTML with an embedded Lottie viewer 0067 """ 0068 format = "html" 0069 bl_label = "Lottie HTML (.html)" 0070 bl_idname = "lottie.export_" + format 0071 0072 filename_ext = "." + format 0073 0074 filter_glob: StringProperty( 0075 default="*." + format, 0076 options={'HIDDEN'}, 0077 maxlen=255, 0078 ) 0079 0080 def _export_animation(self, animation): 0081 blender_export.lottie.exporters.export_embedded_html(animation, self.filepath) 0082 0083 0084 registered_classes = [LottieExporterTgs, LottieExporterLottie, LottieExporterHtml]