diff options
author | Campbell Barton <ideasman42@gmail.com> | 2013-03-26 08:06:46 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2013-03-26 08:06:46 +0400 |
commit | 80793a9d08334f3bc16e55a26f25f6141a5fbeab (patch) | |
tree | f78ea6450cfc7c18bf6e9fae359b0cb8aad2b366 /io_mesh_stl | |
parent | f3d326b3172daf9975083ebfdd23de69fc2a333e (diff) |
fix [#34682] STL importer ValueError exception
Diffstat (limited to 'io_mesh_stl')
-rw-r--r-- | io_mesh_stl/blender_utils.py | 1 | ||||
-rw-r--r-- | io_mesh_stl/stl_utils.py | 18 |
2 files changed, 8 insertions, 11 deletions
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): |