UV unwrap from view for fonts

Hy All

I’m a python/blender rookie trying to build a little script who creates a font object with text in it, transform it to a mesh, UV-unwrap it from view, add a material to it and then renders it.

So far i have everything working except the uv-unwrapping from view.

I have a hard time understanding how the unwrapping works… if someone know more then me, ill be more then happy to learn.

Here parts of my code:

myFontCurve = bpy.data.curves.new(type=“FONT”,name=“font”)
myFontOb = bpy.data.objects.new(“myFontOb”,myFontCurve)

myFontOb.data.body = character # “my text”


Set Material

mat = bpy.data.materials[‘Material’]

We use nodes here…

mat.use_nodes = True
backgroundfile = “/home/phil/Dokumente/Work/Alphabet Builder/Materials/71378.jpg”
mat.node_tree.nodes[“ColorTexture”].image = bpy.data.images.load(backgroundfile)

# Assign Material to Object                                           

if myFontOb.data.materials:
myFontOb.data.materials[0] = mat

bpy.data.objects[“myFontOb”].uv.project_from_view(orthographic=False, correct_aspect=True, clip_to_bounds=False, scale_to_bounds=False)

Render the letter

output = outputdir + "/Athene - Character " + character + “.jpg”
bpy.context.scene.render.filepath = output
bpy.ops.render.render(write_still = True)