Commit b3e27469 authored by Guillaume Seguin's avatar Guillaume Seguin

Change ascii vs binary stl detection criterion

parent 36e597a8
...@@ -102,8 +102,14 @@ class stl: ...@@ -102,8 +102,14 @@ class stl:
self.facetloc = 0 self.facetloc = 0
if filename is None: if filename is None:
return return
self.f = list(open(filename)) with open(filename) as f:
if not self.f[0].startswith("solid"): data = f.read()
if "facet normal" in data[1:300] and "outer loop" in data[1:300]:
lines = data.split("\n")
for line in lines:
if not self.parseline(line):
return
else:
print "Not an ascii stl solid - attempting to parse as binary" print "Not an ascii stl solid - attempting to parse as binary"
f = open(filename, "rb") f = open(filename, "rb")
buf = f.read(84) buf = f.read(84)
...@@ -130,9 +136,6 @@ class stl: ...@@ -130,9 +136,6 @@ class stl:
self.facetsmaxz+=[(max(map(lambda x:x[2], facet[1])), facet)] self.facetsmaxz+=[(max(map(lambda x:x[2], facet[1])), facet)]
f.close() f.close()
return return
for i in self.f:
if not self.parseline(i):
return
def translate(self, v = [0, 0, 0]): def translate(self, v = [0, 0, 0]):
matrix = [ matrix = [
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment