Blender GUI vs. Blender Python API

Is it possible to do (more or less) everything, what can be done with the Blender GUI also using the blender python API / python scripts?

And if so - what would be the best way to approach python scripting for blender?

I am asking because I would like to experiment with genetic algorithms / genetic programming and CG - and still would be happy about a GUI to further work on the generated results.
I was using Maya for a while but would be much happyer if the same would be possible with a free tool like blender.

Thanks, Dietrich

Well, yes.

Objects can be created, duplicated, possitioned with the python API.
And you can put keystrokes into the blender Qeue as if you where typing the commands.
You can have a full python install and use all python functions.
File read and write to decode/use external data.

I’d say blender is more flexible here then Maya.
A good start on blender python is here:
http://www.blender.org/modules/documentation/236PythonDoc/index.html
Don’t let the coders language scare you off.

No you can’t do everything blender gui can do. you can build a small gui for the script, but it will be limited in his scripting window. So you can build interface tu run the script. it can’t be introduced in the blender GUi yet as mel does though.

The best aproach would be to do it as a quick tools for automatisation tricks. as the scripp itself can be accessed in the blender gui, or do a script to do his job at start on the selected object and only ask for option via popup message. This is for now the cleanest integration in blender gui…

Hi whatever, hi gabio,

thanks for your answers!

I was able to create mesh objects - but couldn’t find any way to create NURBS for example. Searching for some information I only found the CurNurb.{c.h} files. Looking at them I had the impression that it is possible to query them but not to create NURBS from scratch or to modify them. The problem is probably my inability to find the right documentation.

Do you know about some text showing how to do that? (Or - if it doesn’t take too much time - could you give a simple code example?)

Features like the curve deform ( http://www.blender3d.org/cms/Curve_Deform.392.0.html ) for example - can they be added to some object and manipulated from a python script using the blender queue (…probably I didn’t understand at all what the blender queue is ?!? - sorry )

I think the same. Maya doesn’t allow to see what is going on behind the API and there is no way for a normal user to add something which is not foreseen. This is another reason I for which I would prefer to use blender. One possibility would be, of course, to add the functionality myself. But looking at the sources I somehow had the impression that this is possible only after some years of blender studies. Are there tutorials etc. which help people to not

?

In the case of Maya I used the command port. I build my own independent program with wxWindows GUI which send commands to Maya and after processed its output. This should be even simpler using Python - just I don’t have any clou how to start…

Probably I should spend some time trying to understand the c sources? - if I just would have more time!

Anyway, Thanks again, Dietrich

Of course, you can use an independant interface manager such as tkinter, it come in the full installation of python. this way you could generate multiple windows for your script. and still operate on blender data. but most of the time it’s not usefull. as the internal tools are good enough.
Tkinter introduction documentation

example you can try right there in blender text window with a full install:


import Tkinter
from Tkinter import *

root = Tk()

w = Label(root, text="Hello, world!")
w.pack()

root.mainloop()

For adding keystrokes to the event queue to invoke Blender functions from within a script, read following discussion:
https://blenderartists.org/forum/viewtopic.php?t=40963&highlight=

Well I did not use it myself yet.
I saw it in a discussion on blender.org http://www.blender.org/modules.php?op=modload&name=phpBB2&file=viewtopic&t=5856
But it seems it has some ugly pitfalls (last posts)

Hi Gabio,

Thanks - I tried your code example. It works fine. But as long as the Tkinter window is up, the blender GUI can’t respond to any input. For this reason I was using the command port in the case of Maya. The Maya main loop reacts to commands send to the command port in the same way as to events entered via the Maya GUI and it is possible to use both interfaces in parallel.

Ok, I will try to use the blender GUI tools :slight_smile: Btw, Do you know if there is something like a geometry manager for the blender widgets? …and how about those nice movable blender Tabs, can they be build using python?

Greetings - Dietrich

Hi Paleajed and Whatever-san,

Thank you for the links to the keystrokes discussions. They look as helpful as they are ugly to look at :). The other way around - a GUI generating python commands and not python generating keystrokes - would be nicer :slight_smile:

  • Dietrich

btw: is there any tutorial about how to “convert” blender c code to python extensions?

No you can’t do everything blender gui can do. you can build a small gui for the script, but it will be limited in his scripting window. So you can build interface tu run the script. it can’t be introduced in the blender GUi yet as mel does though

I may be wrong, but is the interface of the latest MakeHuman script not done in the 3D viewport?
(See the MH screenshots here: http://www.dedalo-3d.com/index.php?filename=SXCOL/makehuman/screenshots.php )

Apropos:
Can you extrude a mesh in python? And how do you move and rotate a set of vertices (the extruded vertices) al once?