Text objects query

First off I’d like to say I’m not new to programming nor blender but I’m new to Blender with python and I’m really enjoying it so thanks to the dev team. That said I have a couple questions:

I have this snippet creates labels for object created by another part of the script (adapted from text.py in"Introduction to Python scripting for Blender 2.5x").

bpy.ops.object.text_add(view_align=True, enter_editmode=True, location=(x, y, .7), rotation=(0, -1.5708, 0))
  bpy.ops.font.delete()
  bpy.ops.font.text_insert(text=name, accent=False)
  bpy.ops.object.editmode_toggle()
  bpy.ops.transform.resize(value=(0.5, 0.5, 0.5))
  textObject=bpy.context.object
  textObject.name=name
  textData=textObject.data
  textData.name=name+"Data"
  textData.extrude=0.2
  textData.font=bpy.data.fonts[0]
  #textData.back=True

Firstly why can’t I do something like

the last line “textData.back=True” was a straight lift from text.py, but it throws up “AttributeError: ‘TextCurve’ object has no attribute ‘back’” if uncommented, so it’s missing a variable somewhere - where can I get more information on why text.py does what it does?

The blender python API has pretty much everything you need to know about using Python in Blender.

Information on the specific object type ‘TextCurve’ that you are having problems with can be found here. As you can see, there is no attribute ‘back’ so that’s why you’re getting the error. Whoever wrote the tutorial you were looking at maybe just didn’t update that code to the most recent revision or something.

In the future, if you run into another problem like this, remember the Blender Python reference, it is amazingly helpful. Sometimes a little vague, but always better than nothing.

thanks for replying - the problem is when I check the api it’s just barebones and a lot of stuff on the net explaining more is out of date.

btw the doc I mentioned is this one, which seems to have been compiled from posts in this forum seems to be from 2010.

page 52

#----------------------------------------------------------
# File text.py
#----------------------------------------------------------
import bpy
import mathfrom math import pi

def run(origin):
    # Create and name TextCurve object
    bpy.ops.object.text_add(location=origin,rotation=(pi/2,0,pi))
    ob = bpy.context.object
    ob.name = ’HelloWorldText’
    tcu = ob.data 
    tcu.name = ’HelloWorldData’
    
    # TextCurve attributes
    tcu.body = "Hello, world"
    tcu.font = bpy.data.fonts[0]
    tcu.offset_x = -9
    tcu.offset_y = -0.25
    tcu.shear = 0.5
    tcu.spacing = 2
    tcu.text_size = 3
    tcu.word_spacing = 4
    
    # Inherited Curve attributest
    cu.extrude = 0.2
    tcu.back = True

if __name__ == "__main__":
    run((0,0,0))