|
| 1 | +import bpy |
| 2 | +import requests |
| 3 | + |
| 4 | + |
| 5 | +def btt_get_world(): |
| 6 | + return bpy.context.scene.world |
| 7 | + |
| 8 | + |
| 9 | +def btt_get_strip_active(): |
| 10 | + scene = bpy.context.scene |
| 11 | + strip = scene.sequence_editor.active_strip |
| 12 | + if strip.type == "TEXT": |
| 13 | + return strip |
| 14 | + |
| 15 | + |
| 16 | +class BTT_to_speech(bpy.types.Operator): |
| 17 | + bl_label = "To Speech" |
| 18 | + bl_idname = "btt.to_speech" |
| 19 | + bl_options = {"REGISTER", "UNDO"} |
| 20 | + |
| 21 | + def execute(self, context): |
| 22 | + world = btt_get_world() |
| 23 | + strip = btt_get_strip_active() |
| 24 | + return {"FINISHED"} |
| 25 | + |
| 26 | + |
| 27 | +class BTT_to_image: |
| 28 | + bl_label = "To Image" |
| 29 | + bl_idname = "btt.to_image" |
| 30 | + bl_options = {"REGISTER", "UNDO"} |
| 31 | + |
| 32 | + def execute(self, context): |
| 33 | + world = btt_get_world() |
| 34 | + strip = btt_get_strip_active() |
| 35 | + return {"FINISHED"} |
| 36 | + |
| 37 | + |
| 38 | +class BTT_menu(bpy.types.Menu): |
| 39 | + bl_label = "AI" |
| 40 | + bl_idname = "btt" |
| 41 | + |
| 42 | + def draw(self, context): |
| 43 | + layout = self.layout |
| 44 | + layout.operator("btt.to_speech", text="To Speech") |
| 45 | + layout.operator("btt.to_image", text="To Image") |
| 46 | + |
| 47 | + |
| 48 | +def menu_func(self, context): |
| 49 | + self.layout.menu(BTT_menu.bl_idname) |
| 50 | + |
| 51 | + |
| 52 | +def register(): |
| 53 | + bpy.utils.register_class(BTT_to_speech) |
| 54 | + bpy.utils.register_class(BTT_to_image) |
| 55 | + bpy.type.SEQUENCER_MT_editor_menus.append(menu_func) |
| 56 | + |
| 57 | + |
| 58 | +def unregister(): |
| 59 | + bpy.utils.unregister_class(BTT_to_speech) |
| 60 | + bpy.utils.unregister_class(BTT_to_image) |
| 61 | + bpy.type.SEQUENCER_MT_editor_menus.remove(menu_func) |
| 62 | + |
| 63 | + |
| 64 | +if __name__ == "__name__": |
| 65 | + register() |
0 commit comments