You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
importbpyimportpyperclipimportchardetimportsubprocessclassSendToSiriShortcutsOperator(bpy.types.Operator):
"""Send text to Siri Shortcuts"""bl_idname="view3d.send_to_siri_shortcuts"bl_label="Send to Siri Shortcuts"defexecute(self, context):
# Get the active text objecttext_obj=context.object# Check if the object is a text objectiftext_obj.type=='FONT':
# Get the text datatext_data=text_obj.data# Detect the encoding of the textencoding=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 Shortcutssubprocess.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'}
defregister():
bpy.utils.register_class(SendToSiriShortcutsOperator)
defunregister():
bpy.utils.unregister_class(SendToSiriShortcutsOperator)
if__name__=="__main__":
register()
The text was updated successfully, but these errors were encountered:
The text was updated successfully, but these errors were encountered: