[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [3541] trunk/py/scripts/addons/ io_mesh_ply/import_ply.py: patch from Chris Want to make ply script more useful when imported from other scripts (returning a mesh).
Campbell Barton
ideasman42 at gmail.com
Tue Jun 26 23:52:17 CEST 2012
Revision: 3541
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=3541
Author: campbellbarton
Date: 2012-06-26 21:52:16 +0000 (Tue, 26 Jun 2012)
Log Message:
-----------
patch from Chris Want to make ply script more useful when imported from other scripts (returning a mesh).
Modified Paths:
--------------
trunk/py/scripts/addons/io_mesh_ply/import_ply.py
Modified: trunk/py/scripts/addons/io_mesh_ply/import_ply.py
===================================================================
--- trunk/py/scripts/addons/io_mesh_ply/import_ply.py 2012-06-26 11:44:50 UTC (rev 3540)
+++ trunk/py/scripts/addons/io_mesh_ply/import_ply.py 2012-06-26 21:52:16 UTC (rev 3541)
@@ -217,12 +217,10 @@
import bpy
-def load_ply(filepath):
- import time
+def load_ply_mesh(filepath, ply_name):
from bpy_extras.io_utils import unpack_face_list
# from bpy_extras.image_utils import load_image # UNUSED
- t = time.time()
obj_spec, obj, texture = read(filepath)
if obj is None:
print('Invalid file')
@@ -292,8 +290,6 @@
for j in range(len_ind - 2):
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.vertices.add(len(obj[b'vertex']))
@@ -358,6 +354,16 @@
for face in mesh.uv_textures[0].data:
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
obj = bpy.data.objects.new(ply_name, mesh)
More information about the Bf-extensions-cvs
mailing list