[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [34314] trunk/blender/release/scripts/op/ io_mesh_ply: add ply import into the file menu.
Campbell Barton
ideasman42 at gmail.com
Fri Jan 14 01:23:21 CET 2011
Revision: 34314
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=34314
Author: campbellbarton
Date: 2011-01-14 00:23:21 +0000 (Fri, 14 Jan 2011)
Log Message:
-----------
add ply import into the file menu.
Modified Paths:
--------------
trunk/blender/release/scripts/op/io_mesh_ply/__init__.py
trunk/blender/release/scripts/op/io_mesh_ply/import_ply.py
Modified: trunk/blender/release/scripts/op/io_mesh_ply/__init__.py
===================================================================
--- trunk/blender/release/scripts/op/io_mesh_ply/__init__.py 2011-01-14 00:06:43 UTC (rev 34313)
+++ trunk/blender/release/scripts/op/io_mesh_ply/__init__.py 2011-01-14 00:23:21 UTC (rev 34314)
@@ -23,16 +23,31 @@
import imp
if "export_ply" in locals():
imp.reload(export_ply)
+ if "import_ply" in locals():
+ imp.reload(import_ply)
import bpy
from bpy.props import *
-from io_utils import ExportHelper
+from io_utils import ImportHelper, ExportHelper
+class ImportPLY(bpy.types.Operator, ImportHelper):
+ '''Load a BVH motion capture file'''
+ bl_idname = "import_mesh.ply"
+ bl_label = "Import PLY"
+
+ filename_ext = ".ply"
+ filter_glob = StringProperty(default="*.ply", options={'HIDDEN'})
+
+ def execute(self, context):
+ from . import import_ply
+ return import_ply.load(self, context, **self.as_keywords(ignore=("filter_glob",)))
+
+
class ExportPLY(bpy.types.Operator, ExportHelper):
'''Export a single object as a stanford PLY with normals, colours and texture coordinates.'''
- bl_idname = "export.ply"
+ bl_idname = "export_mesh.ply"
bl_label = "Export PLY"
filename_ext = ".ply"
@@ -64,16 +79,22 @@
row.prop(self, "use_colors")
-def menu_func(self, context):
+def menu_func_import(self, context):
+ self.layout.operator(ImportPLY.bl_idname, text="Stanford (.ply)")
+
+
+def menu_func_export(self, context):
self.layout.operator(ExportPLY.bl_idname, text="Stanford (.ply)")
def register():
- bpy.types.INFO_MT_file_export.append(menu_func)
+ bpy.types.INFO_MT_file_import.append(menu_func_import)
+ bpy.types.INFO_MT_file_export.append(menu_func_export)
def unregister():
- bpy.types.INFO_MT_file_export.remove(menu_func)
+ bpy.types.INFO_MT_file_import.remove(menu_func_import)
+ bpy.types.INFO_MT_file_export.remove(menu_func_export)
if __name__ == "__main__":
register()
Modified: trunk/blender/release/scripts/op/io_mesh_ply/import_ply.py
===================================================================
--- trunk/blender/release/scripts/op/io_mesh_ply/import_ply.py 2011-01-14 00:06:43 UTC (rev 34313)
+++ trunk/blender/release/scripts/op/io_mesh_ply/import_ply.py 2011-01-14 00:23:21 UTC (rev 34314)
@@ -302,13 +302,17 @@
uv[:] = ply_uv[j]
if colindices:
- # XXX25 TODO
- '''
+ faces = obj['face']
for i, f in enumerate(vcol_lay.data):
+ # XXX, colors dont come in right, needs further investigation.
ply_col = mesh_colors[i]
- for j, col in enumerate(f.col):
+ if len(faces[i]) == 4:
+ f_col = f.color1, f.color2, f.color3, f.color4
+ else:
+ f_col = f.color1, f.color2, f.color3
+
+ for j, col in enumerate(f_col):
col.r, col.g, col.b = ply_col[j]
- '''
mesh.update()
@@ -318,12 +322,11 @@
obj = bpy.data.objects.new(ply_name, mesh)
scn.objects.link(obj)
scn.objects.active = obj
+ obj.select = True
print('\nSuccessfully imported %r in %.3f sec' % (filepath, time.time() - t))
-def main():
- load_ply("/fe/ply/shark.ply")
-
-if __name__ == '__main__':
- main()
+def load(operator, context, filepath=""):
+ load_ply(filepath)
+ return {'FINISHED'}
More information about the Bf-blender-cvs
mailing list