Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PYTHON Meta AI - Make Blender Talk to Siri Shorcuts #1353

Open
enzyme69 opened this issue May 8, 2024 · 3 comments
Open

PYTHON Meta AI - Make Blender Talk to Siri Shorcuts #1353

enzyme69 opened this issue May 8, 2024 · 3 comments

Comments

@enzyme69
Copy link
Owner

enzyme69 commented May 8, 2024

import bpy
import pyperclip
import chardet
import subprocess

class SendToSiriShortcutsOperator(bpy.types.Operator):
    """Send text to Siri Shortcuts"""
    bl_idname = "view3d.send_to_siri_shortcuts"
    bl_label = "Send to Siri Shortcuts"

    def execute(self, context):
        # Get the active text object
        text_obj = context.object

        # Check if the object is a text object
        if text_obj.type == 'FONT':
            # Get the text data
            text_data = text_obj.data
            
            # Detect the encoding of the text
            encoding = chardet.detect(text_data.body.encode())['encoding']
            
            # Copy the text to the clipboard (encode to utf-8 and decode to string)
            clipboard_content = text_data.body.encode('utf-8').decode('utf-8')
            pyperclip.copy(clipboard_content)
            
            # Send the clipboard content to Siri Shortcuts
            subprocess.run(['shortcuts', 'run', 'Clipboard Kanji'])
            
            # Print the text (encode to utf-8 and decode to string)
            print(clipboard_content)
        else:
            print("Please select a text object")
        return {'FINISHED'}

def register():
    bpy.utils.register_class(SendToSiriShortcutsOperator)

def unregister():
    bpy.utils.unregister_class(SendToSiriShortcutsOperator)

if __name__ == "__main__":
    register()
@enzyme69
Copy link
Owner Author

enzyme69 commented May 9, 2024

In case the CLIPBOARD is displaying weird characters, run Blender from the Terminal in macOS.

@enzyme69
Copy link
Owner Author

enzyme69 commented May 9, 2024

Screenshot 2024-05-09 at 08 44 24 Screenshot 2024-05-09 at 08 44 43

@enzyme69
Copy link
Owner Author

enzyme69 commented May 9, 2024

BLEND
kanji_game_010.blend.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant