copy as script operator for the console, so you can copy input from a console for use in a textblock.

This commit is contained in:
2012-08-19 21:32:18 +00:00
parent 59c8c645c3
commit 257c6de9ac
5 changed files with 68 additions and 0 deletions

View File

@@ -290,6 +290,40 @@ def autocomplete(context):
return {'FINISHED'}
def copy_as_script(context):
sc = context.space_data
lines = [
"import bpy",
"import bpy.context as C",
"import bpy.data as D",
"from mathutils import *",
"from math import *",
"",
]
for line in sc.scrollback:
text = line.body
type = line.type
if type == 'INFO': # ignore autocomp.
continue
if type == 'INPUT':
if text.startswith(PROMPT):
text = text[len(PROMPT):]
elif text.startswith(PROMPT_MULTI):
text = text[len(PROMPT_MULTI):]
elif type == 'OUTPUT':
text = "#~ " + text
elif type == 'ERROR':
text = "#! " + text
lines.append(text)
context.window_manager.clipboard = "\n".join(lines)
return {'FINISHED'}
def banner(context):
sc = context.space_data
version_string = sys.version.strip().replace('\n', ' ')