diff --git a/add_mesh_BoltFactory/createMesh.py b/add_mesh_BoltFactory/createMesh.py index 3fd892e32356543fa3df3a391e8e365a3d56866b..f6562072478790b34034b875abe14d252200f034 100644 --- a/add_mesh_BoltFactory/createMesh.py +++ b/add_mesh_BoltFactory/createMesh.py @@ -2085,7 +2085,9 @@ def Create_New_Mesh(props, context, align_matrix): mesh = bpy.data.meshes.new(sMeshName) - mesh.add_geometry((len(verts)), 0, int(len(faces))) + mesh.vertices.add(len(verts)) + mesh.faces.add(len(faces)) + mesh.vertices.foreach_set("co", unpack_list(verts)) mesh.faces.foreach_set("vertices_raw", unpack_face_list(faces)) diff --git a/add_mesh_pipe_joint.py b/add_mesh_pipe_joint.py index 129acb2b95e4d830938cbdc0c263a20774969ed9..96c351addb6d8aff5cbefbcdc0b108d15b9cebf8 100644 --- a/add_mesh_pipe_joint.py +++ b/add_mesh_pipe_joint.py @@ -68,7 +68,7 @@ v0.9.4 - Creating of the pipe now works in mesh edit mode too. Thanks to ideasman42 (Campbell Barton) for his nice work on the torus script code :-). v0.9.3 - Changed to a saner vertex/polygon creation process (previously - my usage of add_geometry could only do quads) + my usage of mesh.faces.add could only do quads) For this I've copied the functions unpack_list and unpack_face_list from import_scene_obj.py. Elbow joint actually supports 3 vertices per circle. diff --git a/io_import_images_as_planes.py b/io_import_images_as_planes.py index ea65284222d353cb05679b79a83cd7458013f03b..e1aa672b4ba5951ab91c55355e0249179742e6bd 100644 --- a/io_import_images_as_planes.py +++ b/io_import_images_as_planes.py @@ -324,7 +324,7 @@ def main(filePath, options, mapping, dimension): plane = createPlaneObj(img, dimension) # Assign Material - plane.data.add_material(mat) + plane.data.materials.link(mat) # Put Image into UVTextureLayer plane.data.uv_textures[0].data[0].image = img @@ -353,7 +353,7 @@ def main(filePath, options, mapping, dimension): plane = createPlaneObj(img, dimension) # Assign Material - plane.data.add_material(mat) + plane.data.materials.link(mat) # Put image into UVTextureLayer plane.data.uv_textures[0].data[0].image = img diff --git a/io_import_scene_mhx.py b/io_import_scene_mhx.py index b8e54e9ba1910090a5124cfd3816d37b232571c2..09ef1fb3c4f47de3e1264c7b0ef832bff2d18178 100644 --- a/io_import_scene_mhx.py +++ b/io_import_scene_mhx.py @@ -1094,12 +1094,14 @@ def parseMesh (args, tokens): if faces: #x = me.from_pydata(verts, [], faces) - me.add_geometry(len(verts), 0, len(faces)) + me.vertices.add(len(verts)) + me.faces.add(len(faces)) me.vertices.foreach_set("co", unpackList(verts)) me.faces.foreach_set("vertices_raw", unpackList(faces)) else: #x = me.from_pydata(verts, edges, []) - me.add_geometry(len(verts), len(edges), 0) + me.vertices.add(len(verts)) + me.edges.add(len(edges)) me.vertices.foreach_set("co", unpackList(verts)) me.edges.foreach_set("vertices", unpackList(edges)) #print(x) @@ -1109,9 +1111,8 @@ def parseMesh (args, tokens): mats = [] for (key, val, sub) in tokens: - if key == 'Verts' or \ - key == 'Edges': - pass + if key in ('Verts', 'Edges'): + pass elif key == 'Faces': parseFaces2(sub, me) elif key == 'MeshTextureFaceLayer': @@ -1124,7 +1125,7 @@ def parseMesh (args, tokens): parseShapeKeys(ob, me, val, sub) elif key == 'Material': try: - me.add_material(loadedData['Material'][val[0]]) + me.materials.link(loadedData['Material'][val[0]]) except: print("Could not add material", val[0]) else: diff --git a/io_import_scene_unreal_psk.py b/io_import_scene_unreal_psk.py index 7e3a035d254f2844600cdd8a92ac6b3f507afe80..6a04955a9f008d118e972a90a80299ab04062f1e 100644 --- a/io_import_scene_unreal_psk.py +++ b/io_import_scene_unreal_psk.py @@ -485,7 +485,9 @@ def pskimport(infile): #Building Mesh #================================================================================================== print("vertex:",len(verts),"faces:",len(faces)) - me_ob.add_geometry(len(verts), 0, int(len(faces)/4)) + me_ob.vertices.add(len(verts)) + me_ob.faces.add(len(faces)//4) + me_ob.vertices.foreach_set("co", unpack_list(verts)) me_ob.faces.foreach_set("vertices_raw", faces) @@ -535,7 +537,7 @@ def pskimport(infile): #= make sure the list isnt too big for material in materials: #add material to the mesh list of materials - me_ob.add_material(material) + me_ob.materials.link(material) #=================================================================================================== # #=================================================================================================== diff --git a/io_mesh_raw/import_raw.py b/io_mesh_raw/import_raw.py index e8a7a4a752bac7ff7db13a806707c6938cf7ba99..850f7002eae8bbf05a0e0a8badfd055abdd8517c 100644 --- a/io_mesh_raw/import_raw.py +++ b/io_mesh_raw/import_raw.py @@ -78,19 +78,22 @@ def readMesh(filename, objName): # Generate verts and faces lists, without duplicates verts = [] coords = {} - index = 0 - + index_tot = 0 + for f in faces: for i, v in enumerate(f): - try: - f[i] = coords[v] - except: - f[i] = coords[v] = index - index += 1 + index = coords.get(v) + + if index is None: + index = coords[v] = index_tot + index_tot += 1 verts.append(v) + fi[i] = index + mesh = bpy.data.meshes.new(objName) - mesh.add_geometry(int(len(verts)), 0, int(len(faces))) + mesh.vertices.add(len(verts)) + mesh.faces.add(len(faces)) mesh.vertices.foreach_set("co", unpack_list(verts)) mesh.faces.foreach_set("vertices_raw", unpack_face_list(faces)) diff --git a/mesh_surface_sketch.py b/mesh_surface_sketch.py index 47445743e6f6f278f8053ad7fbcd1e7551c8d077..a7ea84e9eed535cbbe9ada6290ac2fb6669181d3 100644 --- a/mesh_surface_sketch.py +++ b/mesh_surface_sketch.py @@ -562,19 +562,19 @@ class GPENCIL_OT_SURFSK_add_surface(bpy.types.Operator): vert_num_in_spline = 1 if selection_U_exists: - ob_ctrl_pts.data.add_geometry(1,0,0) + ob_ctrl_pts.data.vertices.add(1) last_v = ob_ctrl_pts.data.vertices[len(ob_ctrl_pts.data.vertices) - 1] last_v.co = verts_ordered_U[i].co vert_num_in_spline += 1 for sp in sketched_splines_parsed: - ob_ctrl_pts.data.add_geometry(1,0,0) + ob_ctrl_pts.data.vertices.add(1) v = ob_ctrl_pts.data.vertices[len(ob_ctrl_pts.data.vertices) - 1] v.co = sp[i] if vert_num_in_spline > 1: - ob_ctrl_pts.data.add_geometry(0,1,0) + ob_ctrl_pts.data.edges.add(1) ob_ctrl_pts.data.edges[len(ob_ctrl_pts.data.edges) - 1].vertices[0] = len(ob_ctrl_pts.data.vertices) - 2 ob_ctrl_pts.data.edges[len(ob_ctrl_pts.data.edges) - 1].vertices[1] = len(ob_ctrl_pts.data.vertices) - 1