This adds a bunch of fixes when exporting svg's from geom's or cncjobs generated from drill files, also adds support for exporting drill files directly as svg's, and should capture any objects that use list within the solid_geometry attribute
This commit is contained in:
parent
10e9fa74c3
commit
a2a1a08e3d
|
@ -1599,9 +1599,8 @@ class App(QtCore.QObject):
|
|||
return
|
||||
|
||||
# Check for more compatible types and add as required
|
||||
# Excellon not yet supported, there seems to be a list within the Polygon Geometry that shapely's svg export doesn't like
|
||||
|
||||
if (not isinstance(obj, FlatCAMGeometry) and not isinstance(obj, FlatCAMGerber) and not isinstance(obj, FlatCAMCNCjob)):
|
||||
if (not isinstance(obj, FlatCAMGeometry) and not isinstance(obj, FlatCAMGerber) and not isinstance(obj, FlatCAMCNCjob)
|
||||
and not isinstance(obj, FlatCAMExcellon)):
|
||||
msg = "ERROR: Only Geometry, Gerber and CNCJob objects can be used."
|
||||
msgbox = QtGui.QMessageBox()
|
||||
msgbox.setInformativeText(msg)
|
||||
|
@ -1729,11 +1728,18 @@ class App(QtCore.QObject):
|
|||
with self.proc_container.new("Exporting SVG") as proc:
|
||||
exported_svg = obj.export_svg()
|
||||
|
||||
# Sometimes obj.solid_geometry can be a list instead of a Shapely class
|
||||
# Make sure we see it as a Shapely Geometry class
|
||||
geom = obj.solid_geometry
|
||||
if type(obj.solid_geometry) is list:
|
||||
geom = [cascaded_union(obj.solid_geometry)][0]
|
||||
|
||||
|
||||
# Determine bounding area for svg export
|
||||
svgwidth = obj.solid_geometry.bounds[2] - obj.solid_geometry.bounds[0]
|
||||
svgheight = obj.solid_geometry.bounds[3] - obj.solid_geometry.bounds[1]
|
||||
minx = obj.solid_geometry.bounds[0]
|
||||
miny = obj.solid_geometry.bounds[1] - svgheight
|
||||
svgwidth = geom.bounds[2] - geom.bounds[0]
|
||||
svgheight = geom.bounds[3] - geom.bounds[1]
|
||||
minx = geom.bounds[0]
|
||||
miny = geom.bounds[1] - svgheight
|
||||
|
||||
# Convert everything to strings for use in the xml doc
|
||||
svgwidth = str(svgwidth)
|
||||
|
|
14
camlib.py
14
camlib.py
|
@ -875,7 +875,14 @@ class Geometry(object):
|
|||
|
||||
:return: SVG Element
|
||||
"""
|
||||
svg_elem = self.solid_geometry.svg(scale_factor=0.05)
|
||||
# Sometimes self.solid_geometry can be a list instead of a Shapely class
|
||||
# Make sure we see it as a Shapely Geometry class
|
||||
geom = self.solid_geometry
|
||||
if type(self.solid_geometry) is list:
|
||||
geom = [cascaded_union(self.solid_geometry)][0]
|
||||
|
||||
# Convert to a SVG
|
||||
svg_elem = geom.svg(scale_factor=0.05)
|
||||
return svg_elem
|
||||
|
||||
class ApertureMacro:
|
||||
|
@ -3345,13 +3352,18 @@ class CNCjob(Geometry):
|
|||
self.solid_geometry = cascaded_union([geo['geom'] for geo in self.gcode_parsed])
|
||||
|
||||
# Convert the cuts and travels into single geometry objects we can render as svg xml
|
||||
if travels:
|
||||
travelsgeom = cascaded_union([geo['geom'] for geo in travels])
|
||||
if cuts:
|
||||
cutsgeom = cascaded_union([geo['geom'] for geo in cuts])
|
||||
|
||||
# Render the SVG Xml
|
||||
# The scale factor affects the size of the lines, and the stroke color adds different formatting for each set
|
||||
# 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")
|
||||
if cuts:
|
||||
svg_elem += cutsgeom.svg(scale_factor=scale, stroke_color="#5E6CFF")
|
||||
|
||||
return svg_elem
|
||||
|
|
Loading…
Reference in New Issue