From 80793a9d08334f3bc16e55a26f25f6141a5fbeab Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 26 Mar 2013 04:06:46 +0000 Subject: fix [#34682] STL importer ValueError exception --- io_mesh_stl/blender_utils.py | 1 + io_mesh_stl/stl_utils.py | 18 +++++++----------- 2 files changed, 8 insertions(+), 11 deletions(-) (limited to 'io_mesh_stl') diff --git a/io_mesh_stl/blender_utils.py b/io_mesh_stl/blender_utils.py index 9c3488eb..7b037716 100644 --- a/io_mesh_stl/blender_utils.py +++ b/io_mesh_stl/blender_utils.py @@ -38,6 +38,7 @@ def create_and_link_mesh(name, faces, points): obj = bpy.data.objects.new(name, mesh) scene.objects.link(obj) + scene.objects.active = obj.select = True diff --git a/io_mesh_stl/stl_utils.py b/io_mesh_stl/stl_utils.py index 1d35acb1..49e8d0f9 100644 --- a/io_mesh_stl/stl_utils.py +++ b/io_mesh_stl/stl_utils.py @@ -145,19 +145,15 @@ def _ascii_read(data): data.readline() while True: - # strip facet normal // or end - data.readline() - - # strip outer loup, in case of ending, break the loop - if not data.readline(): + l = data.readline() + if not l: break - yield [tuple(map(float, data.readline().split()[1:])) - for _ in range(3)] - - # strip facet normalend and outerloop end - data.readline() - data.readline() + # if we encounter a vertex, read next 2 + l = l.lstrip() + if l.startswith(b'vertex'): + yield [tuple(map(float, l_item.split()[1:])) + for l_item in (l, data.readline(), data.readline())] def _binary_write(filename, faces): -- cgit v1.2.3