Help, please creating basic text mesh in Blender 2.56 beta using Python (Newbie)

Hi There

I’m new to using Python in Blender. Although I do have (very limited) previous experience using Python 3. (Now using Blender 2.56 beta)
I’ve spent the day trying to get some initial traction on learning this, but as with anything new, it has been a challenge to identify and structure what I need to learn, in what order, etc…
I’ve been through Ira Krakow’s (basic) Blender 2.5 + Python videos on YouTube, and also have been referencing the blender 250 python docs online.
(and a few other resources).

I am in the first instance trying to create a text object from the Python console.

So far my two main attempts (which will demonstrate that I clearly don’t properly understand yet) have been the following pieces of code entry into the Python console:

import blf
blf.draw(0,‘hello’)

(The console appears to accept this, but no mesh appears to be created in the 3D view).

Also this code:

import bpy
bpy.ops.object.text_add(view_align=False, enter_editmode=False, location=(0, 0, 0), rotation=(0, 0, 0), layers=(False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False))

(The above code, which was copied and pasted from the ‘OperatorList.txt’ doc causes the console to report ‘CANCELLED’, as do other commands taken from the ‘OperatirList.txt’ doc, and no mesh appears to be created)

Obviously I’ve got big gaps in my understanding.

Any assistance would be very much appreciated!

Thanks

Regards

Paul

I’m no expert, and haven’t used the script window for much ever since the modifications for 2.5x API. Anyway, I have been able to add functions using the toolbox for add-ons. Have a look at the included scripts in the [Blender install path]/2.5x/scripts/addons folder for working examples you can use as references for various operations. The “add_mesh_gears.py” and Bolt Factory are two good examples (simple and very complex) that you may find helpful.

I added a section to the “Blender 3D: Noob to Pro” Wikibook introducing scripting for 2.5x. You can read it here
http://en.wikibooks.org/wiki/Blender_3D:_Noob_to_Pro/Advanced_Tutorials/Python_Scripting/Introduction_New

The reason why your text_add call is returning {‘CANCELLED’} is because all the Layers flags are False. Did you notice a little message flash up in the Info window up top, saying “Property ‘layer’ has no values set”?. Try defaulting the arguments:

bpy.ops.object.text_add()

and you will see that the text object appears, and the call returns {‘FINISHED’}.