I'm very new to Blender and its Python API so bear with me. I'm trying to create a cube and put an image texture (unwrapped, so that the entire image can be seen on the cube face) on each of its faces. I have everything but the unwrapping part working - the images show on the cube faces but they are cropped. Here's what I have, thanks in advance for the help!
def make_cube_with_material(size, x, y, z):
bpy.ops.mesh.primitive_cube_add(size=size, enter_editmode=False, align='WORLD', location=(x, y, z))
obj = bpy.context.active_object
obj.data.materials.append(random.choice(mats))
me = obj.data
for edge in me.edges:
edge.use_seam = True
bm = bmesh.new() # create an empty BMesh
bm.from_mesh(me) # fill it in from a Mesh
bpy.ops.object.mode_set(mode='EDIT')
bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='FACE', action='ENABLE')
for face in bm.faces:
face.material_index = 0
face.select = True
bpy.ops.uv.unwrap()
bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='FACE', action='DISABLE')
bpy.ops.object.mode_set(mode='OBJECT')
# Finish up, write the bmesh back to the mesh
bm.to_mesh(me)
bm.free() # free and prevent further access
mats
is a collection of those materials? $\endgroup$