Skip to content
Snippets Groups Projects
Commit 2e8e879c authored by Campbell Barton's avatar Campbell Barton
Browse files

patch from Chris Want to make ply script more useful when imported from other...

patch from Chris Want to make ply script more useful when imported from other scripts (returning a mesh).
parent 28f9d813
No related branches found
No related tags found
No related merge requests found
...@@ -217,12 +217,10 @@ def read(filepath): ...@@ -217,12 +217,10 @@ def read(filepath):
import bpy import bpy
def load_ply(filepath): def load_ply_mesh(filepath, ply_name):
import time
from bpy_extras.io_utils import unpack_face_list from bpy_extras.io_utils import unpack_face_list
# from bpy_extras.image_utils import load_image # UNUSED # from bpy_extras.image_utils import load_image # UNUSED
t = time.time()
obj_spec, obj, texture = read(filepath) obj_spec, obj, texture = read(filepath)
if obj is None: if obj is None:
print('Invalid file') print('Invalid file')
...@@ -292,8 +290,6 @@ def load_ply(filepath): ...@@ -292,8 +290,6 @@ def load_ply(filepath):
for j in range(len_ind - 2): for j in range(len_ind - 2):
add_face(verts, (ind[0], ind[j + 1], ind[j + 2]), uvindices, colindices) add_face(verts, (ind[0], ind[j + 1], ind[j + 2]), uvindices, colindices)
ply_name = bpy.path.display_name_from_filepath(filepath)
mesh = bpy.data.meshes.new(name=ply_name) mesh = bpy.data.meshes.new(name=ply_name)
mesh.vertices.add(len(obj[b'vertex'])) mesh.vertices.add(len(obj[b'vertex']))
...@@ -358,6 +354,16 @@ def load_ply(filepath): ...@@ -358,6 +354,16 @@ def load_ply(filepath):
for face in mesh.uv_textures[0].data: for face in mesh.uv_textures[0].data:
face.image = image face.image = image
return mesh
def load_ply(filepath):
import time
t = time.time()
ply_name = bpy.path.display_name_from_filepath(filepath)
mesh = load_ply_mesh(filepath, ply_name)
scn = bpy.context.scene scn = bpy.context.scene
obj = bpy.data.objects.new(ply_name, mesh) obj = bpy.data.objects.new(ply_name, mesh)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment