I'm really new to blender (2.9) and I'm exploring its Python API. I'm also comparing the API with the normal GUI tools. At the moment I'm trying to create a textured plane without the use of the function:
bpy.ops.mesh.primitive_plane_add()
The main reason is for experimenting purposes. For this reason I'm trying to use BMesh and so far i got this:
import bmesh
# Construct the bmesh cube and assign it to the blender mesh.
bm = bmesh.new()
bmesh.ops.create_grid(bm, x_segments = 1, y_segments = 1, size = 1.0)
#bmesh.ops.create_cube(bm, size = 1.0)
# Finish up, write the bmesh into a new mesh
me = bpy.data.meshes.new("Chessboard_Plan")
bm.to_mesh(me)
bm.free()
# Add the mesh to the scene
obj = bpy.data.objects.new("Chessboard_Plan", me)
bpy.context.collection.objects.link(obj)
# Select and make active
bpy.context.view_layer.objects.active = obj
obj.select_set(True)
The Plane is shown correctly:
I can give it a base color:
but I when i try to apply an image texture i only get this weird blue shade:
it should appear like this:
Is there something wrong with the way I create the plane and put it in the scene?