Skip to content

Instantly share code, notes, and snippets.

@zeffii
Forked from anonymous/ufkoot.py
Created April 14, 2015 08:37
Show Gist options
  • Save zeffii/fd2c41659e4c9bef284a to your computer and use it in GitHub Desktop.
Save zeffii/fd2c41659e4c9bef284a to your computer and use it in GitHub Desktop.
import bpy
class InfoToTextBlock(bpy.types.Operator):
"""Tooltip"""
bl_idname = "info.to_text_block"
bl_label = "Simple Copy To TextBlock Operator"
def execute(self, context):
bpy.ops.info.report_copy()
fdata = context.window_manager.clipboard
bpy.data.texts.new('copied_from_console')
bpy.data.texts['copied_from_console'].write(fdata)
return {'FINISHED'}
class CustomInfoMenu(bpy.types.Menu):
bl_label = "Info To Textblok"
bl_idname = "INFO_MT_custom_menu"
def draw(self, context):
layout = self.layout
layout.operator("info.to_text_block")
def draw_item(self, context):
layout = self.layout
layout.menu(CustomInfoMenu.bl_idname)
def register():
bpy.utils.register_class(InfoToTextBlock)
bpy.utils.register_class(CustomInfoMenu)
bpy.types.INFO_MT_window.append(draw_item)
def unregister():
bpy.utils.unregister_class(InfoToTextBlock)
bpy.utils.unregister_class(CustomInfoMenu)
bpy.types.INFO_MT_window.remove(draw_item)
if __name__ == "__main__":
register()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment