Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2012-08-20 01:32:18 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-08-20 01:32:18 +0400
commit257c6de9ace4c66d6054d10712204b62aa8ace2f (patch)
tree7dd8c53ce5a20e7586728df22f71dc6ad5815bd7 /release/scripts/modules/console_python.py
parent59c8c645c351af4473d869d543b0465225b9f85e (diff)
copy as script operator for the console, so you can copy input from a console for use in a textblock.
Diffstat (limited to 'release/scripts/modules/console_python.py')
-rw-r--r--release/scripts/modules/console_python.py34
1 files changed, 34 insertions, 0 deletions
diff --git a/release/scripts/modules/console_python.py b/release/scripts/modules/console_python.py
index d32606eb0b0..6e8fee07c0f 100644
--- a/release/scripts/modules/console_python.py
+++ b/release/scripts/modules/console_python.py
@@ -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', ' ')