Ah ha…
I found this …
delete any meshes or text in the current drawing
def removeObjects( scn ):
for ob in scn.objects:
if ob.type == ‘FONT’ or ob.type == ‘MESH’:
scn.objects.unlink( ob )
scn = bpy.context.scene
removeObjects( scn )
create several materials - each text line will use a different material
def makeMaterial(name, diffuse, specular, alpha):
mat = bpy.data.materials.new(name)
mat.diffuse_color = diffuse
mat.diffuse_shader = ‘LAMBERT’
mat.diffuse_intensity = 1.0
mat.specular_color = specular
mat.specular_shader = ‘COOKTORR’
mat.specular_intensity = 0.5
mat.alpha = alpha
mat.ambient = 1
return mat
def setMaterial(ob, mat):
me = ob.data
me.materials.append(mat)
red = makeMaterial(‘Red’, (1, 0, 0), (1, 1, 1), 1)
blue = makeMaterial(‘BlueSemi’, (0, 0, 1), (1, 1, 1), 0.5)
green = makeMaterial(‘GreenSemi’, (0, 1, 0), (1, 1, 1), 0.5)
yellow = makeMaterial(‘YellowSemi’, (1, 1, 0), (1, 1, 1), 0.5)
Create and name TextCurve object #1
bpy.ops.object.text_add(
location=(-3, 0, 3.6),
rotation=(pi/2, 0, 0))
ob = bpy.context.object
ob.name = ‘Text1’
TextCurve attributes
ob.data.name = ‘TextData1’
ob.data.body = “THREE.JS”
fnt = bpy.data.fonts.load(‘C:\Windows\Fonts\Impact.ttf’)
ob.data.font = fnt
ob.data.size = 2.75
Inherited Curve attributes
ob.data.bevel_depth = 0.1
ob.data.bevel_resolution = 5
ob.data.extrude = 0.5
setMaterial(ob, red)
bpy.ops.object.convert(target=‘MESH’, keep_original=False)
Create and name TextCurve object #2
bpy.ops.object.text_add(
location=(-3, 0, 1.6),
rotation=(pi/2, 0, 0))
ob = bpy.context.object
ob.name = ‘Text2’
TextCurve attributes
ob.data.name = ‘TextData2’
ob.data.body = “TEXT”
fnt = bpy.data.fonts.load(‘C:\Windows\Fonts\Georgia.ttf’)
ob.data.font = fnt
ob.data.bevel_depth = 0.1
ob.data.bevel_resolution = 5
ob.data.size = 3
Inherited Curve attributes
ob.data.extrude = 0.5
setMaterial(ob, green)
bpy.ops.object.convert(target=‘MESH’, keep_original=False)
Create and name TextCurve object #3
bpy.ops.object.text_add(
location=(-3, 0, 0),
rotation=(1.51, 0, 0))
ob = bpy.context.object
ob.name = ‘Text3’
TextCurve attributes
ob.data.body = “DEMO”
ob.data.name = ‘TextData3’
fnt = bpy.data.fonts.load(‘C:\Windows\Fonts\coopbl.ttf’)
ob.data.font = fnt
ob.data.bevel_depth = 0.1
ob.data.bevel_resolution = 5
ob.data.size = 2.32
Inherited Curve attributes
ob.data.extrude = 0.5
setMaterial(ob, yellow)
bpy.ops.object.convert(target=‘MESH’, keep_original=False)