What can i do with Python ?


i see tons of stuff related to Python/Blender - but i can’t find an answer for the most simple question: for what purposes can i use Python scripting in Blender ?

Is it a simple 3d api i can use without running blender in the background ? Makes it only sence to use it with running blender in background, i.e. to manipulate some objects in an open project ? If it runs only with Blender - can i nevertheless thing of it like a full-featuered 3d api ? Can i create 3d objects and do with them what i want or can i only access and manipulate objects created in an running blender-project ?







like i already wrote - i can’t find answers to my simple question. Would someone please help me ? This questions can be answered with to sentences.

I already wrote all the sentences in the second link in my sig. The two links I posted are full of examples of what you can do using Python inside Blender. All the Import/Export options in the File menu are Python Scripts.


Thankyou for the links, there were a little bit helpful, but maybe i’m to stupid: they didn’t answer my basic questions, i’ll try it this way (and i’ll add my other questions):

  1. Can i use the Blender Python-API without running Blender in Background ?

yes [ ] no [ ]

  1. Can i generate a static 3D picture with Python using all Blender 3d features without having to define the used world/objects/scenes/textures/ etc… in a blender-project before, i.e. just like i would do with a java 3d engine api (code and run) ?

yes [ ] no [ ]

  1. Can i thing of blender/python as a normal 3d api - for using it ONLY for programming purposes without working on blender-projects in the blender-GUI ?

yes [ ] no [ ]

  1. If its necesarry to run Blender in background to run Python scripts - can i do that “quietly” in the background, i.e. like the jre does with java class files ?

yes [ ] no [ ]

  1. Can i use sockets :slight_smile: in the python scripts, if the versions of blender/python fit together ?

yes [ ] no [ ]

  1. If i can use sockets and Blender has to run in background - could i run a python script as a server (endless-loop) to wait for (local) connections (for generating pics by client requests), so that blender would ‘never’ been shut down ?

yes [ ] no [ ]

  1. If yes, would that be stable ?

yes [ ] no [ ]


To all your previous question I’ll answer once.
You don’t need Blender to work with python.
You can build you own program only in python. by getting the package @ www.python.org.

Don’t forget: we wont code it for you.

I know what python is and…

Don’t forget: we wont code it for you.

…I really don’t need answers like this - can you say me what your problem is ? I’m researching/coding in a dozen different APIs and technologies see what’s the best to realize my project (i even wrote an own engine for realizing this purpose), i don’t need to tell you how much time it would cost to read 20 sites of introduction + coding samples for every technology/product/api…so why shouldn’t i ask on the forum when somebody can answer this in a minute ?

When i’m helping programers or students on coding-forums, i never forgot that the most difficult thing is getting started and introducing to a technology - how easy it may be for me. So i’m just answering and avoiding posting unnecesarry things like you do.

Thanks to the other guys for helping, still hoping for further answers.

Ok lemme try.

Hope that helps

Very nice macouno, very nice - thank you very much. Especially answers 1 and 2 helped me categorising and understanding Python/Blender.

Now, its one of the favourites and i can introduce into the technics by the posted links.

Answers 1 and 2 should be copied to every PythonInBlender FAQ (if its a frequently asked question or not). :wink:

  1. Can i use sockets :slight_smile: in the python scripts, if the versions of blender/python fit together ?

yes no

Yes. I don’t know how sockets work in Python, but I doubt Blender has much to do with it. If it works in a normal Python script, it should work in a Blender script.

could i run a python script as a server (endless-loop) to wait for (local) connections (for generating pics by client requests), so that blender would ‘never’ been shut down ?

yes no

For this I think it might be best to write a separate application (Python script or a “real” program in C++ or so) to handle all the networking and socket business. It would be a server for blend files. If you send it a blend file, the server-application will launch an instance of Blender (in command-line mode), feed it the blend file and then retrieve the created image file. The Blender instance will close automatically after it’s finished with rendering, so a separate instance will be launched for each blend file.
I think this would be the most stable and easiest solution :expressionless:

For documentation:
The most up-to-date BPy doc
About Blender in command-line mode (You can feed it both blend and Python files!)

Regarding question #4: Blender has to be running. There is no runtime environment for Blender. The Python API for Blender is an interface that allows Python to access the data and functions in Blender. It is mainly used to add functionality to Blender as “scripts” or “plugins” run from within Blender. I think you are asking about running Python seperately and making calls to Blender to create content. It could probably be done, but why? What kind of files would you be trying to serve?

Thank you very much. You are answering exactly what i want to know.


Yes, in principle, that’s what i want to do. But starting an instance of blender for every request is what i want to avoid due to perfomance reasons. I thought about some blender instances each running a python-script with an endless loop (server) in the script, so detaining the blender process to exit because the script runs endless and blender should wait for the end of the script (don’t know if this works and how stable it would be). But it would be an interesting attempt.


I need a kind of picture server which generates pics with 3d stuff - shouldn’t be too slow. The generated picture should be an easy png. I started writing an “PHP-static3D” engine, but after 3 months i saw that it would take some further year to have a good engine. The performance was also really bad (even for generating just one frame). I started researching for several gl-bindings in Java, game engines, pure Java engines, thinking of making my own bindings with swig and so on, then i heard of blender. It would be an atypical solution, but maybe i could try that. What i like here is that i would have all i need in one tool and that i could maybe use all this great features and effects from python.

But i’ll have to thing about it, i still don’t know if blender should be used for such a “technical” application.

I browsed through the docs some days ago and i’m still wondering how small the API is, so maybe there is more to be prepared in a blender project and less to be done with python scripting. I would need it the other way round, so i have to read what one can do…

I’m sorry for my previous reply. From your 3 first posts you looked like you didn’t know python at all, from this point of view I didn’t took your simples questions seriously.
Your last post really explain it all.
In short you want a 3D database with render capability for the web right?

This is what you can do:
1-Server side: Write a simple API to store and manage 3D data which can be a SQL server.
2-When you are ready to render: just export all your data in a python script file with a unique name which if executed in blender would automatically build a scene from scratch (if you’r just dealing with polygon this is really straight forward).
3-call blender with “blender -b -P (your scene script)”. This will start a new instance of blender and import all your 3D data. Then in this same script you can set everything and then start a render. If there is something you can’t set in a script you can just save it as default with CTRL-U.
4-by setting where to render in the script you can then get a png out of it in less than 5 sec if it’s a simple scene. You can even import stuff like Object and material from other Blend file and build a scene from that.

(edit) concerning running multiple instance of blender, the way to call blender here with -b is very fast and take little to no memory. This would let you render more than one file at a time if you even need it.

Sounds like Java would be your best bet, unless you want to do some serious coding. Java already has a few 3D APIs, both server and client side.
You also may want to check out OpenLazlo - http://www.openlaszlo.org/. It’s an open source flash server.
Also check out http://freshmeat.net and http://sourceforge.net. They have all kinds of client-server apps that interface with Blender or POVRay or a bunch of other open source 3d graphic apps.

No problem, i see you’re a moderator and so i can understand that you often have stress :wink:

Thank you very much for your detailed explaining, that will be very helpfull !


There are some good java 3d-apis (or others in C/C++ like Irrlicht but i don’t like C++), but the to most featured in Java, xith3d and jmonkeyengine are full game engines and the class-diagrams are based on that need, for my application i thing i would have a big overhead and introduce into things i wouldn’t need later. There are 2 more interesting java apis, jogl an lwjgl, that are gl-bindings (xith3d and jmonkeyengine depend on them), but here i would have to do everything from raw opengl - that’s ok but maybe in blender i could start one layer above. There is also a very very good pure Java 3d engine one can also use in applets (idx3d.ch), but it hasn’t basic features like collision detection (i need that too for static stuff), shadows, some texturing features…

I didn’t know they have client-server apps interfacing with blender on sourceforge (!) - i’ll check it out ! Thanks a lot.