How intergrated is Python in Blender so far ?

Scripting in Blender with Python, and working on the API

Moderators: jesterKing, stiv

Post Reply
Money_YaY!
Posts: 442
Joined: Wed Oct 23, 2002 2:47 pm

How intergrated is Python in Blender so far ?

Post by Money_YaY! »

I ask this to find out how much power Python script scould swing in Blender as a real feature. I am still going on about how I wish people would write in ReDraw() more often for adjustments of things like sliders and such so to get a visual feedback. But I am told that Blenders python is not at that point yet for it to be used like a 'real' featured with the speed of a hard coded feature.

Anyway, just curious.

an-toni
Posts: 0
Joined: Wed Mar 17, 2004 5:20 pm

Post by an-toni »

I also had some notes about places where more visual feedback is needed, but don't remember what that was..

To answer your question, as far as I know, Python can't be used to modify Blender itself at all. There can be only scripts run in the bpython environment that the embedded interpreter and there the Blender Python API provide. IIRC, they can use a special Space-type called ScriptSpace for GUI but I don't know the details about that.

Possible architectural changes (for Blender 3) have been mentioned, but I don't know the current status. Wrote some notes about the issue arlier this summer -- for one perspective (pondering Blender as a Python library) with links to some of the discussions see http://studio.kyperjokki.fi/engine/PythonBlender (feel free to add updates / views / whatever as comments there)

~Toni

Money_YaY!
Posts: 442
Joined: Wed Oct 23, 2002 2:47 pm

Post by Money_YaY! »

an-toni wrote:I also had some notes about places where more visual feedback is needed, but don't remember what that was..

To answer your question, as far as I know, Python can't be used to modify Blender itself at all. There can be only scripts run in the bpython environment that the embedded interpreter and there the Blender Python API provide. IIRC, they can use a special Space-type called ScriptSpace for GUI but I don't know the details about that.

Possible architectural changes (for Blender 3) have been mentioned, but I don't know the current status. Wrote some notes about the issue arlier this summer -- for one perspective (pondering Blender as a Python library) with links to some of the discussions see http://studio.kyperjokki.fi/engine/PythonBlender (feel free to add updates / views / whatever as comments there)

~Toni
:( Need more power for scripters. What can be done ?

flippyneck
Posts: 0
Joined: Thu Jul 31, 2003 10:34 am
Contact:

Post by flippyneck »

an-toni,

I read your piece on Blender in Python. Just thought that you might be interested in comparing it with Endo:

http://p212.ezboard.com/fnendowingsmira ... =306.topic

It's an attempt to port Wings 3D to Python. I've tried it and it works well enough, but the performance is definitely slower than that of Wings itself. Blender is of course much more complex than wings...

theeth
Posts: 500
Joined: Wed Oct 16, 2002 5:47 am
Location: Montreal
Contact:

Post by theeth »

flippyneck wrote:an-toni,

I read your piece on Blender in Python. Just thought that you might be interested in comparing it with Endo:

http://p212.ezboard.com/fnendowingsmira ... =306.topic

It's an attempt to port Wings 3D to Python. I've tried it and it works well enough, but the performance is definitely slower than that of Wings itself. Blender is of course much more complex than wings...
Interesting. Were any test made to see if running it with psyco gave it "standard" or more speed?

Martin
Life is what happens to you when you're busy making other plans.
- John Lennon

an-toni
Posts: 0
Joined: Wed Mar 17, 2004 5:20 pm

Post by an-toni »

thanks for info flippyneck, will definitely check that out! just a quick comment before that:

you mention "porting to python" -- i wonder if that actually is a port, which would definitely explain it being slower, or just packaging the c(?) stuff as python modules.

some repetition to make sure: that idea about PythonBlender is not about porting the core, as i guess it should remain as c at least for the near future, but just packaging the c stuff as it is so that it can be used from Python, and that non-cpu intensive things for the Blender itself could be written in it (like the OOPS view of perhaps a history tree / undo).

perhaps Endo does that, in which case it would be really interesting to know the reasons for slowness .. will check out later

oh and regarding theeths note on Psyco, which indeed is interesting, Pyrex also seems to rock (at least based on the seemingly succesfull rewrite of Soya3d with that, check https://gna.org/projects/soya/ if interested (my engine of choice currently))

~Toni

flippyneck
Posts: 0
Joined: Thu Jul 31, 2003 10:34 am
Contact:

Post by flippyneck »

Endo is 100% Python; it's a rewrite from scratch which explains the lack of speed. Wings is in Erlang. I just checked the Endo sourceforge site and it looks like the guy has got around to adding some more stuff after about a year's inactivity.

My programming knowledge is limited, but what I get from an-toni's piece is that by writing only the extremely intensive parts Blender's core in a compiled language and exposing it to Python, building on that core and prototyping new functionality would become extremely quick. Super Tuhopuu if you like...

As for Psyco, Theeth, I didn't try I'm afraid.

oyster
Posts: 0
Joined: Sat Mar 29, 2003 4:41 pm
Contact:

Post by oyster »

flippyneck wrote:an-toni,

I read your piece on Blender in Python. Just thought that you might be interested in comparing it with Endo:

http://p212.ezboard.com/fnendowingsmira ... =306.topic

It's an attempt to port Wings 3D to Python. I've tried it and it works well enough, but the performance is definitely slower than that of Wings itself. Blender is of course much more complex than wings...
It seems that Endo has been suspended. I e-mailed to markluffel with some suggestions, but got no reply. So I have to post the content of the e-mail on the wings forum. I think a all-in-Python application can give an external script most of the access to the program itself more easily: for example, the script-driven-objs mentioned on the wings forum.

And today, a thougt came into my head when I wrote http://www.elysiun.com/forum/viewtopic.php?t=27600. if python script can access the render output window, a new render engine can be added easily without modification in Blender C++ file source: Blender sence is passed to a render engine either by variable or by file, the engine calculates and returns the result, then python script brings up a output window to draw the rendered image.

an-toni
Posts: 0
Joined: Wed Mar 17, 2004 5:20 pm

Post by an-toni »

surely an all-python app is more easily accessible from python, as nothing needs to be done for it.

however, as all of Blender is in c(++), and c is very good for performance which is critical in many places, a Python rewrite does not make sense. a good thing about Python is that interfacing with c is not hard. the official Python implementation itself is written in c, as is much(?) of the standard library. also e.g. the imaging library (PIL) etc. are written in c as far as i know, and that is or at least has been necessary for cpu intensive tasks such as image processing. and of course the Blender module usable from bpython is another example of that.

so flippyneck, you got it right, except that i'm not even suggesting limiting the c in the very cpu intensive parts, but keeping basically all existing work (the c code) in place -- just hope that it would be usable from Python too so that the core could be extended with it (of course that might lead to rewrites of some of the existing parts (e.g. GUI config?)), and that parts (e.g. the IPO module? not to mention renderers like Oyster kindof mentione) could be used without Blender by other apps.

~Toni

Post Reply