|
|
@@ -869,18 +869,25 @@ class Geometry(object):
|
|
|
"""
|
|
|
self.solid_geometry = [cascaded_union(self.solid_geometry)]
|
|
|
|
|
|
- def export_svg(self):
|
|
|
+ def export_svg(self, scale_factor=0.00):
|
|
|
"""
|
|
|
Exports the Gemoetry Object as a SVG Element
|
|
|
|
|
|
:return: SVG Element
|
|
|
"""
|
|
|
- # Sometimes self.solid_geometry can be a list instead of a Shapely class
|
|
|
- # Make sure we see it as a Shapely Geometry class
|
|
|
+ # Make sure we see a Shapely Geometry class and not a list
|
|
|
geom = cascaded_union(self.flatten())
|
|
|
|
|
|
+ # scale_factor is a multiplication factor for the SVG stroke-width used within shapely's svg export
|
|
|
+
|
|
|
+ # If 0 or less which is invalid then default to 0.05
|
|
|
+ # This value appears to work for zooming, and getting the output svg line width
|
|
|
+ # to match that viewed on screen with FlatCam
|
|
|
+ if scale_factor <= 0:
|
|
|
+ scale_factor = 0.05
|
|
|
+
|
|
|
# Convert to a SVG
|
|
|
- svg_elem = geom.svg(scale_factor=0.05)
|
|
|
+ svg_elem = geom.svg(scale_factor=scale_factor)
|
|
|
return svg_elem
|
|
|
|
|
|
class ApertureMacro:
|
|
|
@@ -3326,17 +3333,26 @@ class CNCjob(Geometry):
|
|
|
|
|
|
self.create_geometry()
|
|
|
|
|
|
- def export_svg(self):
|
|
|
+ def export_svg(self, scale_factor=0.00):
|
|
|
"""
|
|
|
Exports the CNC Job as a SVG Element
|
|
|
|
|
|
- :return: SVG Element
|
|
|
+ :scale_factor: float
|
|
|
+ :return: SVG Element string
|
|
|
"""
|
|
|
+ # scale_factor is a multiplication factor for the SVG stroke-width used within shapely's svg export
|
|
|
+ # If not specified then try and use the tool diameter
|
|
|
+ # This way what is on screen will match what is outputed for the svg
|
|
|
+ # This is quite a useful feature for svg's used with visicut
|
|
|
+
|
|
|
+ if scale_factor <= 0:
|
|
|
+ scale_factor = self.options['tooldia'] / 2
|
|
|
|
|
|
- # This appears to match up distance wise with inkscape
|
|
|
- scale = self.options['tooldia'] / 2
|
|
|
- if scale == 0:
|
|
|
- scale = 0.05
|
|
|
+ # If still 0 then defailt to 0.05
|
|
|
+ # This value appears to work for zooming, and getting the output svg line width
|
|
|
+ # to match that viewed on screen with FlatCam
|
|
|
+ if scale_factor == 0:
|
|
|
+ scale_factor = 0.05
|
|
|
|
|
|
# Seperate the list of cuts and travels into 2 distinct lists
|
|
|
# This way we can add different formatting / colors to both
|
|
|
@@ -3360,9 +3376,9 @@ class CNCjob(Geometry):
|
|
|
# It's better to have the travels sitting underneath the cuts for visicut
|
|
|
svg_elem = ""
|
|
|
if travels:
|
|
|
- svg_elem = travelsgeom.svg(scale_factor=scale, stroke_color="#F0E24D")
|
|
|
+ svg_elem = travelsgeom.svg(scale_factor=scale_factor, stroke_color="#F0E24D")
|
|
|
if cuts:
|
|
|
- svg_elem += cutsgeom.svg(scale_factor=scale, stroke_color="#5E6CFF")
|
|
|
+ svg_elem += cutsgeom.svg(scale_factor=scale_factor, stroke_color="#5E6CFF")
|
|
|
|
|
|
return svg_elem
|
|
|
|