Code snippets. Introduction to Python scripting in Blender 2.5x

this link doesnt work for me… with regular download, is says " please wait 15 seconds, and when they are down it desnt seem to be downloading anything… can you upload it somewhere else? for example Rapidshare seems to work correctly… thanks

It is the first time in years I have heard anybody say something good about Rapidshare. :slight_smile: But ok, here is an alternative link.

https://rapidshare.com/files/457417262/Code_snippets_updated_for_Blender_257_2011_04_14.zip

Thank you, this link works for me!

Horrible change they did … No not for me, you now need to be a (maybe free) member of rapidshare

Hi, Thomas, I have some questions about RNA and ID properties : what kind of data can we store in these? lets say that i have a cube and i want a slider that gives me the ability to change his segments like the most add primitive operators do… can I do this with RNA? And how it should be done? Can you give some simple examples, on ID and RNA usage for modeling?

From what you wrote it looks like if I add something like ID property for a cube for example, it will belong only to cube, but not for all meshes i(cone, torus, plane, etc.,)but if I add this property like RNA it will be assigned to all types of meshes, am I right? The second question is how we proxify the object? You wrote that in order to access the RNA or ID properties after linking the object in the new file we should proxify the object!

And, some different example, if I make a more complex primitive, lets say add human head for example, and I want a slider to control the mesh density can I do this with ID or RNA? and if not, then how can I do something like that?

Sorry if my questions are stupid, but im a newbie in programming, so please forgive me! Besides that your book is very great and easy to follow and understand… thank you very much and cheers! Have a nice day!

Hi, Thomas, what do you think about keep this notes on the wiki? So it’s possible to have multi languages and a more quick update

Hello Thomas

I’m using Blender 2.57 trunk 36147 (downloaded from BF) and NONE of your scripts work.
It can be me it can be my computer but I can’t run anything at least without getting an error (most times) AT THE LAST LINE (run(…)).
And your scripts doesn’t match to the ones in the pdf.

Can you do a little upgrade?

Can not confirm your complaints (SVN of today 36281) run, what I checked
eg. multimaterial …

Attachments


Have you done any modifications to the script according to the pdf?

Just checked and the script doesn’t match to the pdf (as I said)

No, the *.py are clear to me … :wink:

Are those *py found in the \object file?
Because those work (but I can’t find he batch.py in that).

*/257/scripts has batch.py (but probably pathes must me adjusted)

Been on internet-free vacation over the Easter break.

I downloaded the snippets from hotfile and saved to a new location. Some paths have to be changed, but otherwise everything works for me, both with official 2.57 and a recent graphicall build. The pdf and python files are the same. I don’t understand how it could be different, because the python files are imported into the LaTeX source with \verbatiminput.

Hi spirit,
I am confused about the different property types myself. The distinction seems to be blurred, since RNA properties are apparently transformed into Id properties when you open a saved file in a new Blender session.

According to the docs at http://wiki.blender.org/index.php/Dev:2.5/Py/API/Intro#Custom_Properties (which I just found), Id properties can only be

  • int, float, string
  • array of ints/floats
  • dictionary (only string keys types on this list)

RNA properties can be anything listed in the docs at http://www.blender.org/documentation/blender_python_api_2_57_release/bpy.props.html .

i think it is also affected the way you define it

like if you define a property as a scene property or locally

if as a scene property i think it will be shown on bottom of world panel and also save with file

this can create a problem in the sense that when you load back thefile/ properties default value will take on the saved value from the file and you loose the old default proeprty defined in the origninal property definition!

test test test

really nice. thanks much!

ValterVB has ported my python cookbook to the wiki format. It is now available at
http://wiki.blender.org/index.php/Dev:2.5/Py/Scripts/Cookbook/Code_snippets

I wish to thank Valter for his work.

The pdf version has also been modified. There is no reason to download the new file if you have the old one, because the only difference is that the license statement in the text has been removed. The code snippets are now licensed under Creative Commons, to comply with the wiki requirements. The new pdf file can be found at
http://hotfile.com/dl/116601588/a03f0bb/Code_snippets_updated_for_Blender_257_2011_05_03.zip.html

That’s really terrific. I’m looking forward to diving into it.

Thank you so much for this, ThomasL and ValterVB. This fills a big gap.