This is an interactive console, similar to Python's own command line interpreter. Since it is embedded in Blender, it has access to all Blender Python modules.
Those completely new to Python are recommended to check the link button above
that points to its official homepage, with news, downloads and documentation.
Usage:<br>
Type your code and hit "Enter" to get it executed.<br>
- Right mouse click: Console Menu (Save output, etc);<br>
- Arrow keys: command history and cursor;<br>
- Shift + arrow keys: jump words;<br>
- Ctrl + Tab: auto compleate based on variable names and modules loaded -- multiple choices popup a menu;<br>
- Ctrl + Enter: multiline functions -- delays executing code until only Enter is pressed.
"""
import Blender
from Blender import *
import sys as python_sys
import StringIO
import types
# Constants
__DELIMETERS__ = '. ,=+-*/%<>&~][{}():'
__LINE_HISTORY__ = 200
global __LINE_HEIGHT__
__LINE_HEIGHT__ = 14
global __FONT_SIZE__
__FONT_SIZE__ = "normal"
'''
# Generic Blender functions
def getActScriptWinRect():
area = Window.GetAreaSize()
area = (area[0]-1, area[1]-1)
for scrInfo in Window.GetScreenInfo(Window.Types['SCRIPT'], 'win', ''):
if scrInfo['vertices'][2]-scrInfo['vertices'][0] == area[0]:
if scrInfo['vertices'][3]-scrInfo['vertices'][1] == area[1]:
return scrInfo['vertices']
return None
'''
class cmdLine:
# cmd: is the command string, or any other message
# add if to the end, reverse will make it the start.
multiLineCode.append('if 1:')
multiLineCode.reverse()
multiLineCode.append(' pass') # Now this is the end
runUserCode('\n'.join(multiLineCode))
# Clear the output based on __LINE_HISTORY__
if len(cmdBuffer) > __LINE_HISTORY__:
cmdBuffer = cmdBuffer[-__LINE_HISTORY__:]
histIndex = cursor = -1 # Reset cursor and history
def actionUpKey():
global histIndex, cmdBuffer
if abs(histIndex)+1 >= len(cmdBuffer):
histIndex = -1
histIndex -= 1
while cmdBuffer[histIndex].type != 0 and abs(histIndex) < len(cmdBuffer):
histIndex -= 1
if cmdBuffer[histIndex].type == 0: # we found one
cmdBuffer[-1].cmd = cmdBuffer[histIndex].cmd
def actionDownKey():
global histIndex, cmdBuffer
if histIndex >= -2:
histIndex = -len(cmdBuffer)
histIndex += 1
while cmdBuffer[histIndex].type != 0 and histIndex != -2:
histIndex += 1
if cmdBuffer[histIndex].type == 0: # we found one
cmdBuffer[-1].cmd = cmdBuffer[histIndex].cmd
def actionRightMouse():
global __FONT_SIZE__
global __LINE_HEIGHT__
choice = Draw.PupMenu('Console Menu%t|Write Input Data (white)|Write Output Data (blue)|Write Error Data (red)|Write All Text|%l|Insert Blender text|%l|Font Size|%l|Help|%l|Quit')