Commit eb17dd55 authored by sumpfralle's avatar sumpfralle

fixed the STL export issue regarding "unit" (see r983)

fixed the order or vertices in STL output to avoid "vertex rotation" (caused no harm but resulted in different ascii output)


git-svn-id: https://pycam.svn.sourceforge.net/svnroot/pycam/trunk@990 bbaffbd6-741e-11dd-a85d-61de82d9cad9
parent 0e42d380
...@@ -28,8 +28,7 @@ import os ...@@ -28,8 +28,7 @@ import os
class STLExporter: class STLExporter:
def __init__(self, model, name="model", created_by="pycam", linesep=None, def __init__(self, model, name="model", created_by="pycam", linesep=None,
comment=None): **kwargs):
# sadly STL does not seem to support comments
self.model = model self.model = model
self.name = name self.name = name
self.created_by = created_by self.created_by = created_by
...@@ -56,7 +55,7 @@ class STLExporter: ...@@ -56,7 +55,7 @@ class STLExporter:
yield " outer loop" yield " outer loop"
# Triangle vertices are stored in clockwise order - thus we need # Triangle vertices are stored in clockwise order - thus we need
# to reverse the order (STL expects counter-clockwise orientation). # to reverse the order (STL expects counter-clockwise orientation).
for point in (triangle.p3, triangle.p2, triangle.p1): for point in (triangle.p1, triangle.p3, triangle.p2):
yield " vertex %f %f %f" % (point.x, point.y, point.z) yield " vertex %f %f %f" % (point.x, point.y, point.z)
yield " endloop" yield " endloop"
yield "endfacet" yield "endfacet"
......
...@@ -108,7 +108,7 @@ class SVGExporter: ...@@ -108,7 +108,7 @@ class SVGExporter:
#TODO: we need to create a unified "Exporter" interface and base class #TODO: we need to create a unified "Exporter" interface and base class
class SVGExporterContourModel(object): class SVGExporterContourModel(object):
def __init__(self, model, comment=None, unit="mm"): def __init__(self, model, unit="mm", **kwargs):
self.model = model self.model = model
self.unit = unit self.unit = unit
......
...@@ -2530,11 +2530,14 @@ class ProjectGui: ...@@ -2530,11 +2530,14 @@ class ProjectGui:
return return
try: try:
file_in = open(filename, "w") file_in = open(filename, "w")
model.export(comment=self.get_meta_data()).write(file_in) model.export(comment=self.get_meta_data(),
unit=self.settings.get("unit")).write(file_in)
file_in.close() file_in.close()
except IOError, err_msg: except IOError, err_msg:
log.error("Failed to save model file: %s" % err_msg) log.error("Failed to save model file: %s" % err_msg)
else: else:
log.info("Successfully stored the current model as '%s'." % \
str(filename))
self.add_to_recent_file_list(filename) self.add_to_recent_file_list(filename)
@gui_activity_guard @gui_activity_guard
......
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