[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [922] trunk/py/scripts/addons/ io_mesh_stl/__init__.py: STL import/export
Bouchard Guillaume
guillaume.bouchard at insa-lyon.fr
Wed Aug 18 15:44:55 CEST 2010
Revision: 922
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-extensions&revision=922
Author: guillaum
Date: 2010-08-18 15:44:55 +0200 (Wed, 18 Aug 2010)
Log Message:
-----------
STL import/export
- can export multiple objects (all selected, not only active one)
- can import multiples stl file at once with the file selector
Modified Paths:
--------------
trunk/py/scripts/addons/io_mesh_stl/__init__.py
Modified: trunk/py/scripts/addons/io_mesh_stl/__init__.py
===================================================================
--- trunk/py/scripts/addons/io_mesh_stl/__init__.py 2010-08-18 09:25:04 UTC (rev 921)
+++ trunk/py/scripts/addons/io_mesh_stl/__init__.py 2010-08-18 13:44:55 UTC (rev 922)
@@ -47,6 +47,9 @@
- Export only one object (the selected one)
"""
+import itertools
+import os
+
import bpy
from bpy.props import *
@@ -70,18 +73,22 @@
bl_idname = "import_mesh.stl"
bl_label = "Import STL"
- filepath = StringProperty(name="File Path",
+ files = CollectionProperty(name="File Path",
description="File path used for importing "
"the STL file",
- maxlen=1024,
- default="")
+ type=bpy.types.OperatorFileListElement)
+ directory = StringProperty()
+
def execute(self, context):
- objName = bpy.path.display_name(self.properties.filepath.split("\\")[-1].split("/")[-1])
- tris, pts = stl_utils.read_stl(self.properties.filepath)
+ paths = (os.path.join(self.properties.directory, name.name) for name in self.properties.files)
- blender_utils.create_and_link_mesh(objName, tris, pts)
+ for path in paths:
+ objName = bpy.path.display_name(path.split("\\")[-1].split("/")[-1])
+ tris, pts = stl_utils.read_stl(path)
+ blender_utils.create_and_link_mesh(objName, tris, pts)
+
return {'FINISHED'}
def invoke(self, context, event):
@@ -118,10 +125,10 @@
default=True)
def execute(self, context):
- ob = context.active_object
+ faces = itertools.chain.from_iterable(
+ blender_utils.faces_from_mesh(ob, self.properties.apply_modifiers)
+ for ob in context.selected_objects)
- faces = blender_utils.faces_from_mesh(ob,
- self.properties.apply_modifiers)
stl_utils.write_stl(self.properties.filepath, faces, self.properties.ascii)
return {'FINISHED'}
@@ -138,7 +145,6 @@
def menu_export(self, context):
- import os
default_path = os.path.splitext(bpy.data.filepath)[0] + ".stl"
self.layout.operator(StlExporter.bl_idname,
text="Stl (.stl)").filepath = default_path
More information about the Bf-extensions-cvs
mailing list