[Bf-taskforce25] python console in Blender 2.5

Toni Alatalo antont at kyperjokki.fi
Wed Apr 1 07:10:46 CEST 2009


On Mar 31, 2009, at 7:40 PM, Stani wrote:

> 1. Running in the blender console:

ah never thought of that, even though am using consoles like that in 
other apps all the time - neat.

i'm not sure how to read these event hacking ideas 'cause all that was 
refactored to 2.5, and AFAIK you've only worked with 2.48 so far, but 
some comments anyway.

> 2.1 extra script panel
> The mouse is placed on on extra script panel which captures the key
> codes to interact with the Blender shell text window. This works the
> best as the whole Blender UI stays responsive. The inconvenience to 
> move
> your mouse above a script window for typing in another text window, is
> worth the effort for having a nicely working IPython console.

well for any tool to work in blender you need to move the mouse to that 
space .. hm except (some?) hotkeys are not like that, e.g. f12 always 
renders.

perhaps this method could be compensated by there being a keybinding 
for switching spaces / jumping to the script space/panel? so could 
write commands to the console, press an alt-tab like thing to switch to 
3d view, rotate the camera there a bit with numpad to see what 
happened, press the keycombo again to return to command prompt to 
continue.. using a console is nicer when hands don't have to leave the 
keyboard :)

> console. I would have liked to propose we use IPython (pure python 
> code,
> BSD license) as a console in Blender 2.5  I could make my current
> IPython wrapper compatible with Blender 2.5 In this wrapper all

+1 on IPython, i love it :)

also the internals of it have been refactored so the 
for-a-long-time-nice featureset is hopefully already provided by a 
clean(er) codebase too.

one thing for the others to note about IPython:
it already has support for macro like usage, at least a parser for 
commands like:
 > rotate 1, 3, 5 .. this kind of macro usage is afaik a 2.5 target and 
has been wanted for long (that's one reason why i've been proposing 
IPython earlier too)

and a system for 'magics', custom commands (like aliases) that you can 
add. one builtin one is:
%hist #shows your previous commands, which you can then re-execute with 
e.g. exec In[21]

that way we could add blender specific commands that are not part of 
the api really but just commands..
%render
%save
%boss

etc. (with the %automagic flag on the magics are run without the 
preceding %)

another nice builtin magic is:
cd /tmp #ipython works as a operatings system shell too, there is a 
special mode for that too

it is largely used to control simulations, make scientific calculations 
etc. - often by non-programmers like scientists that just want to 
visualize their data .. or control some electromagnetic real life 
cannon. so the goals with Blender targetting artists are kind of nicely 
aligned. of course it is a powerful dev env for programmers too, but 
not only that.

> Blender, but unfortunately there is a problem. The only problem is that
> AFAIK IPython does not support yet python 3. However it might when

they'll certainly port at some point, don't recall if anyone has looked 
at it yet, but there is the 2to3 tool and during last year they added a 
lot of unit tests so hopefully is easy enough. i guess there hasn't 
been a need yet, perhaps blender2.5 will be the first who wants it 
done.

> If wished, I can commit myself to do the python coding for this. This
> gives you one less issue to worry about. Of course someone else needs 
> to
> expose the above api functionality from c. As I develop SPE (a python

i think that would be great, Campbell and Brecht obviously have loads 
on their plates already, and you know this area very well. the exposing 
part they'll be taking care of anyway AFAIK.

i'm mostly busy with another project (adding python support to a 
'virtual worlds viewer' / 'generic game client', 
http://www.realxtend.org/) which is ogre and a c++ written event system 
etc. - just got py embedded there a couple of weeks ago and have been 
testing adding first things to api etc, and plan to add a console too, 
so will be working on related stuff (and get more intimate with the py 
c api again, now from c++) but probably don't have time to contribute 
directly on the Blender side now (hopefully after some months we get to 
switch focus to content creation tools within that project and start to 
look at Blender integrations seriously :)

> Stani

~Toni



More information about the Bf-taskforce25 mailing list