Commit d3371866 authored by Guillaume Seguin's avatar Guillaume Seguin

Fix and cleanup STL plater export

parent feefd003
...@@ -309,14 +309,16 @@ class StlPlater(Plater): ...@@ -309,14 +309,16 @@ class StlPlater(Plater):
sf = open(name.replace(".", "_") + ".scad", "w") sf = open(name.replace(".", "_") + ".scad", "w")
facets = [] facets = []
for i in self.models.values(): for i in self.models.values():
r = i.rot r = i.rot
rot = [0, 0, r] if r else None
o = i.offsets o = i.offsets
sf.write('translate([%s, %s, %s]) rotate([0, 0, %s]) import_stl("%s");\n' % (str(o[0]), str(o[1]), str(o[2]), r, os.path.split(i.filename)[1])) co = i.centeroffset
if r != 0: trans = [o[0] + co[0], o[1] + co[1], o[2] + co[2]] if any(o) or any(co) else [0, 0, 0]
i = i.rotate([0, 0, r]) sf.write('translate([%s, %s, %s]) rotate([0, 0, %s]) import_stl("%s");\n' % (trans[0], trans[1], trans[2], r, os.path.split(i.filename)[1]))
if o != [0, 0, 0]: if rot:
i = i.translate([o[0], o[1], o[2]]) i = i.rotate(rot)
if trans:
i = i.translate(trans)
facets += i.facets facets += i.facets
sf.close() sf.close()
stltool.emitstl(name, facets, "plater_export") stltool.emitstl(name, facets, "plater_export")
......
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