Beginner's Guide to Scripting in Blender.

Hi, I’m rather new to Blender and have worked with both 2.49 and 2.53. I have also learned a some Python 2.6 and would like to learn how write a simple script (to do anything simple), but am not sure how to actually integrate Python with Blender. Can someone point me towards a “beginner’s” guide for scripting in Blender with Python.

I also just began learning Python 3, but am not there yet where I could use it with any level of success in Blender or otherwise.

Thank you for your help,
Fulano

The info about how to use Pyton in Blender 2.53 is yet ‘wide spread’ but see scripting examples
http://blenderartists.org/forum/forumdisplay.php?f=11

A good start is to learn using the Scripting ( click a little bit left to Default above and chose ‘Scripting’)
Below left you find a python-console!

Your first attempts try to see ‘things’ working:
type there


o = bpy.data.objects['Cube'] # the startup Cube!
od = o.data
od
od.verts
od.verts.values() #after dir(od.verts)
[/code/
etc.

type e.g. there bpy. and than “ctrl-space” … to see what bpy supports

Thank you PKHG, I appreciate the help, but I hate to admit, I’m still a bit lost. I need the “paint-by-numbers” version of scripting at my stage. I was hoping to find a tutorial or a PDF that would guide me through some simple examples -maybe like making a ball bounce, or changing a cube’s dimensions in a certain manner, etc. It can be either the 2.49 or 2.53 versions, I just need to see how Python sets its hooks into blender so that I can begin to figure it out.

Thanks again,
Fulano

Hey Fulano,
I just started scripting in blender as well, and honestly the best way I’ve found is by reading other’s code bundled with blender in the .blender/scripts/ folder (2.49) or 2.53/scripts/ folder (2.53). So far though, 2.53 has a much steeper learning curve imho. Anyway, try reading those along with the API - been the best tools yet for learning this. GLHF

It’s a tutorial for blender scripting in alpha 1, but I’m sure you can learn from it.

My beginners guide would be a bit cynic: “Please, avoid using Python with Blender”. Python has a certain philosophy about zen of programming, it means being very well designed high level programming language with purigism and ideologies. Blender just throws these kind of ideologies away. It is understandable, because Blender is a practical inhouse animation tool, made with heart, and without planning. If you keep a certain amount of criticism in your thinking now, it will surely pay back after some years.

If you are in the scripting (TEXT) area, there are three ‘buttons’ one to show linenumbers, one to show colours, and the third to wrap around (if the window is too small)

If you can read GERMAN, look here for a PDF
http://www.blendpolis.de/viewtopic.php?f=37&t=26779&start=20

Maybe a little bit obsolete(some changes in the Api), but nevertheless … a start.

Hi Killogge, thank for the suggestion. I didn’t know those were there. I will look into that.

Fulano

Hi Xochipilli, very cool!!! Thank you very much, these videos are great!!!

Fulano

Hi Richard, I had seen that book during my research of the subject matter. I plan to purchase it, but I’m reading the Essential Blender first and also ordered Digital Lighting and Rendering. I need to get through those before I purchase another book. However, thank you for the suggestion, at least I now know its a recommended read.

Fulano

Hi SnifiX. I’m a bit confused and maybe that’s because I’m new to Blender…why would you dissuade me from using Python in Blender? Is there something else that works as well or better? I’m open to learning other languages.

Fulano

Hi PKHG, thank you very much for your help! I actually used the Translate feature in Google and it converted the page to English for me… : )

Thanks again,
Fulano

My opinion is a bit negative for the integration of Python in Blender. Personally I prefer using just Python without Blender. Grow your skills in pure Python development, so after a while you get the glue to use for example OpenGL or other geometric or image packages. GUI design is a problem by itself, for me there is no favourite GUI toolkit, and I have found it very frustrating. I’m about hoping Blender will have an own Python powered GUI toolkit some time in future, and maybe planning it while you learn Python, would be a nice and instructive ideal.

I’m thinking that the pythonic way would be something like this:

$ python
>>> from blender3 import *
>>> cube=Cube()
>>> dir(cube)
[something instructive here,...]
>>> cube.rotate(degrees=25)
>>> vertices=select(cube.vertices(face=upface))
>>> vertices.scale(1.25)
>>> view=renderwindow()
>>> view.render([cube,lamp,camera])
>>> view.close()

This is not possible yet, but working towards the goal would surely be at least educational.