Posted: Sun Oct 20, 2002 12:44 am
Joined: 19 Oct 2002
Posts: 13
An interactive python mode for blender would be great.
I often start the python interpreter while testing a script to check a code stub without executing the entire thing. There is no direct way to do this in blender. Adding a 'terminal' window mode to blender seems like the obvious solution, but perhaps there is something more elegant.
Besides allowing testing of scripts this creates a command-line-interface for blender that would handle repetitive but single use actions like...
| Code: |
for bone in skeleton:
if bone.x > 0:
bone.name = 'r'+bone.name
else:
bone.name = 'l'+bone.name
|
Posted: Sun Oct 20, 2002 4:52 am
Joined: 16 Oct 2002
Posts: 1177
I usually use a dummy script to do that kind of things, but yes, a command line window could be very useful.
Martin
_________________
Life is what happens to you when you're busy making other plans.
- John Lennon
Posted: Tue Oct 22, 2002 11:17 am
Joined: 16 Oct 2002
Posts: 2
This code snippet creates a simple Python shell to the Blender console. It handles neither multi-line statements nor exceptions, but creating a fully compatible shell is not a problem. Anyway, I don't know if this solves your problem.
| Code: |
while 1:
try:
try:
s = raw_input('>>> ')
except EOFError:
print
break
if s and s[0] != '#':
s = s + '\n'
c = compile(s, '<stdin>', 'single')
exec c
except:
raise
|
- Joonas
Posted: Thu Oct 24, 2002 5:06 am
Joined: 19 Oct 2002
Posts: 13
To get a console window in MacOS X you must call Blender from the command line. Something like:
/Applications/BlenderPublisher.app/Contents/MacOS/blenderpublisher
You could also create a link to the executable and name it "blender" for easy access. Say:
ln /Application/...publisher ~/blender.
I also edited the script:
| Code: |
import traceback
while 1:
try:
try:
s = raw_input('>>> ')
except EOFError:
print traceback.print_exc()
break
if s == 'exit':
break
if s and s[0] != '#':
s = s + '\n'
exec compile(s, '<stdin>', 'single')
except:
print traceback.print_exc()
|
It would be elegant if there was a toggle button on the script window that executed a script after it was selected in the drop-down menu. This would make selecting GUI scripts (or this console hack) like selecting a window mode. I think it would be consistent with the rest of the interface.[/code]