Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorM Bouchard Guillaume <guillaume.bouchard@liris.cnrs.fr>2010-08-18 17:44:55 +0400
committerM Bouchard Guillaume <guillaume.bouchard@liris.cnrs.fr>2010-08-18 17:44:55 +0400
commit2a7343b8314ab4bbb6ec1e9a3fc26d7fe16a259b (patch)
tree9c383992ba35641cfa06b4839963993237d231be /io_mesh_stl
parent6b83cb96d0ae1d5b3b8860726f89fdc9554a7d87 (diff)
STL import/export
- can export multiple objects (all selected, not only active one) - can import multiples stl file at once with the file selector
Diffstat (limited to 'io_mesh_stl')
-rw-r--r--io_mesh_stl/__init__.py30
1 files changed, 16 insertions, 14 deletions
diff --git a/io_mesh_stl/__init__.py b/io_mesh_stl/__init__.py
index cd1ac79f..a5450cec 100644
--- a/io_mesh_stl/__init__.py
+++ b/io_mesh_stl/__init__.py
@@ -41,12 +41,11 @@ Issues:
Import:
- Does not handle the normal of the triangles
- Does not handle endien
-
-Export:
- - Does not do the object space transformation
- - Export only one object (the selected one)
"""
+import itertools
+import os
+
import bpy
from bpy.props import *
@@ -70,17 +69,21 @@ class StlImporter(bpy.types.Operator):
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)
+
+ 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)
+ blender_utils.create_and_link_mesh(objName, tris, pts)
return {'FINISHED'}
@@ -118,10 +121,10 @@ class StlExporter(bpy.types.Operator):
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 +141,6 @@ def menu_import(self, context):
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