Hy All
Im a blender noob trying to get a font texturised in blender. Thats how i plan to do it:
- create the font (is a curve)
- convert the curve to mesh
- uv_unwrap the mesh from view (i need just plain unwrapping, since its 2d)
- add material
- render
So far all works except the unwrap which leaves me with a horridly distorted mapping of the image.
myFontCurve = bpy.data.curves.new(type="FONT",name="font")
myFontOb = bpy.data.objects.new("myFontOb",myFontCurve)
myFontOb.data.body = "my text"
bpy.context.collection.objects.link(myFontOb)
# Set Material
mat = bpy.data.materials['Material'] #Material Nodes Settings are done in gui
# We use nodes here...
mat.use_nodes = True
backgroundfile = "pathtoaffile.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
else:
myFontOb.data.materials.append(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 = "path to file.jpg"
bpy.context.scene.render.filepath = output
bpy.ops.render.render(write_still = True)
My attempt to do so with unwrap_from_view fail with "'Object' object has no attribute 'uv'".
Like i said, im a rookie and help would be very much appreciated.
If somebody could point me in the right direction, that would be awesome.
Thanks you