1
$\begingroup$

I have been using this addon for years and it has prevented me from moving to 2.8 till now, but I thought I would try my best to convert it

I managed to convert almost all of the script and am just commenting two sections out, the faces and UV

I have spent a couple of days googleing and reading through every post but I just cant get it to work, I know tessface has been depreciated, but everything I try fails

The commented lines below are the ones I cant get to work.

I think i would be happy if I could just get the faces to work at least!

Help me Obi-wan you are my only hope!

def make_mesh(verteces, faces, normals, uvs, global_matrix):
mesh = bpy.data.meshes.new('name')
mesh.vertices.add(len(verteces))
mesh.vertices.foreach_set("co", unpack_list(verteces))
#mesh.tessface.add(len(faces))
#mesh.tessface.foreach_set("vertices_raw", unpack_face_list(faces))

index = 0
for vertex in mesh.vertices:
    vertex.normal = normals[index]
    index += 1



#uvtex = mesh.tessface_uv_layers.new()
#uvtex.name = "UV"

#for face, uv in enumerate(uvs):
#    data = uvtex.data[face]
#    data.uv1 = uv[0]
#    data.uv2 = uv[1]
#    data.uv3 = uv[2]
#mesh.update(calc_tessface=False, calc_edges=False)

obj = bpy.data.objects.new('name', mesh)
# apply transformation matrix
obj.matrix_world = global_matrix
bpy.context.collection.objects.link(obj)  # link object to collection
$\endgroup$

1 Answer 1

1
$\begingroup$

Got the faces with one line

def make_mesh(verteces, faces, normals, uvs, global_matrix):
mesh = bpy.data.meshes.new('name')

mesh.from_pydata(verteces,[],faces)

obj = bpy.data.objects.new('name', mesh)
# apply transformation matrix
obj.matrix_world = global_matrix
bpy.context.collection.objects.link(obj)  # link object to collection
```
$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .