[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [1895] trunk/py/scripts/addons/ io_mesh_stl: fix [#26895] STL import in Win 7 64bit
Campbell Barton
ideasman42 at gmail.com
Thu May 5 10:27:08 CEST 2011
Revision: 1895
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=1895
Author: campbellbarton
Date: 2011-05-05 08:27:07 +0000 (Thu, 05 May 2011)
Log Message:
-----------
fix [#26895] STL import in Win 7 64bit
Modified Paths:
--------------
trunk/py/scripts/addons/io_mesh_stl/__init__.py
trunk/py/scripts/addons/io_mesh_stl/blender_utils.py
Modified: trunk/py/scripts/addons/io_mesh_stl/__init__.py
===================================================================
--- trunk/py/scripts/addons/io_mesh_stl/__init__.py 2011-05-04 16:21:10 UTC (rev 1894)
+++ trunk/py/scripts/addons/io_mesh_stl/__init__.py 2011-05-05 08:27:07 UTC (rev 1895)
@@ -77,7 +77,7 @@
"the STL file",
type=bpy.types.OperatorFileListElement)
- directory = StringProperty()
+ directory = StringProperty(subtype='DIR_PATH')
def execute(self, context):
from . import stl_utils
@@ -88,8 +88,14 @@
if not paths:
paths.append(self.filepath)
+ if bpy.ops.object.mode_set.poll():
+ bpy.ops.object.mode_set(mode='OBJECT')
+
+ if bpy.ops.object.select_all.poll():
+ bpy.ops.object.select_all(action='DESELECT')
+
for path in paths:
- objName = bpy.path.display_name(path.split("\\")[-1].split("/")[-1])
+ objName = bpy.path.display_name(os.path.basename(path))
tris, pts = stl_utils.read_stl(path)
blender_utils.create_and_link_mesh(objName, tris, pts)
Modified: trunk/py/scripts/addons/io_mesh_stl/blender_utils.py
===================================================================
--- trunk/py/scripts/addons/io_mesh_stl/blender_utils.py 2011-05-04 16:21:10 UTC (rev 1894)
+++ trunk/py/scripts/addons/io_mesh_stl/blender_utils.py 2011-05-05 08:27:07 UTC (rev 1895)
@@ -30,14 +30,17 @@
mesh = bpy.data.meshes.new(name)
mesh.from_pydata(points, [], faces)
- ob = bpy.data.objects.new(name, mesh)
- bpy.context.scene.objects.link(ob)
-
# update mesh to allow proper display
mesh.validate()
mesh.update()
+ scene = bpy.context.scene
+ obj = bpy.data.objects.new(name, mesh)
+ scene.objects.link(obj)
+ obj.select = True
+
+
def faces_from_mesh(ob, apply_modifier=False, triangulate=True):
'''
From an object, return a generator over a list of faces.
More information about the Bf-extensions-cvs
mailing list