- fixed issue when exporting DXF and not settings the units

- added the posibility to export the Geometry in different DXF formats (previously it was hard coded to the AutoCAD 2010): R12, R2000, R2004, R2007, R2010, R2013, R2018
- fixed the camlib.Geometry.bounds() method such that it is calculated correctly for Geometry objects created in the Geometry Editor
This commit is contained in:
Marius Stanciu
2021-03-11 04:50:41 +02:00
committed by Marius
parent d464c1e18a
commit 2f57e97a21
7 changed files with 82 additions and 6 deletions

View File

@@ -7,6 +7,12 @@ CHANGELOG for FlatCAM beta
=================================================
11.03.2021
- fixed issue when exporting DXF and not settings the units
- added the posibility to export the Geometry in different DXF formats (previously it was hard coded to the AutoCAD 2010): R12, R2000, R2004, R2007, R2010, R2013, R2018
- fixed the camlib.Geometry.bounds() method such that it is calculated correctly for Geometry objects created in the Geometry Editor
7.03.2021
- Levelling Plugin - mare sure that there are no duplicate seed points when creating Voronoi polygons

View File

@@ -245,6 +245,9 @@ class PreferencesUIManager:
"geometry_segx": self.ui.geometry_defaults_form.geometry_adv_opt_group.segx_entry,
"geometry_segy": self.ui.geometry_defaults_form.geometry_adv_opt_group.segy_entry,
# Geometry Export
"geometry_dxf_format": self.ui.geometry_defaults_form.geometry_exp_group.dxf_format_combo,
# Geometry Options
"tools_mill_tooldia": self.ui.geometry_defaults_form.geometry_gen_group.cnctooldia_entry,
# "tools_mill_offset_type": 0, # _('Path')

View File

@@ -0,0 +1,45 @@
from PyQt5 import QtWidgets, QtCore
from appGUI.GUIElements import FCLabel, FCComboBox
from appGUI.preferences.OptionsGroupUI import OptionsGroupUI
import gettext
import appTranslation as fcTranslate
import builtins
fcTranslate.apply_language('strings')
if '_' not in builtins.__dict__:
_ = gettext.gettext
class GeometryExpPrefGroupUI(OptionsGroupUI):
def __init__(self, decimals=4, parent=None):
super(GeometryExpPrefGroupUI, self).__init__(self, parent=parent)
self.setTitle(str(_("Geometry Export")))
self.decimals = decimals
# Plot options
self.export_options_label = FCLabel("<b>%s:</b>" % _("Export Options"))
self.export_options_label.setToolTip(
_("The parameters set here are used in the file exported\n"
"when using the File -> Export -> Export DXF menu entry.")
)
self.layout.addWidget(self.export_options_label)
grid0 = QtWidgets.QGridLayout()
grid0.setColumnStretch(0, 0)
grid0.setColumnStretch(1, 1)
self.layout.addLayout(grid0)
# Excellon non-decimal format
self.dxf_format_label = FCLabel("%s:" % _("Format"))
self.dxf_format_label.setToolTip(
_("Autodesk DXF Format used when exporting Geometry as DXF.")
)
self.dxf_format_combo = FCComboBox()
self.dxf_format_combo.addItems(['R12', 'R2000', 'R2004', 'R2007', 'R2010', 'R2013', 'R2018'])
grid0.addWidget(self.dxf_format_label, 0, 0)
grid0.addWidget(self.dxf_format_combo, 0, 1)

View File

@@ -2,6 +2,7 @@ from PyQt5 import QtWidgets
from appGUI.preferences.geometry.GeometryEditorPrefGroupUI import GeometryEditorPrefGroupUI
from appGUI.preferences.geometry.GeometryAdvOptPrefGroupUI import GeometryAdvOptPrefGroupUI
from appGUI.preferences.geometry.GeometryExpPrefGroupUI import GeometryExpPrefGroupUI
from appGUI.preferences.geometry.GeometryOptPrefGroupUI import GeometryOptPrefGroupUI
from appGUI.preferences.geometry.GeometryGenPrefGroupUI import GeometryGenPrefGroupUI
@@ -24,6 +25,8 @@ class GeometryPreferencesUI(QtWidgets.QWidget):
self.geometry_gen_group = GeometryGenPrefGroupUI(decimals=self.decimals)
self.geometry_gen_group.setMinimumWidth(220)
self.geometry_exp_group = GeometryExpPrefGroupUI(decimals=self.decimals)
self.geometry_exp_group.setMinimumWidth(220)
self.geometry_opt_group = GeometryOptPrefGroupUI(decimals=self.decimals)
self.geometry_opt_group.setMinimumWidth(300)
self.geometry_adv_opt_group = GeometryAdvOptPrefGroupUI(decimals=self.decimals)
@@ -32,7 +35,13 @@ class GeometryPreferencesUI(QtWidgets.QWidget):
self.geometry_editor_group.setMinimumWidth(250)
self.layout.addWidget(self.geometry_gen_group)
self.layout.addWidget(self.geometry_opt_group)
self.vlay = QtWidgets.QVBoxLayout()
self.vlay.addWidget(self.geometry_opt_group)
self.vlay.addWidget(self.geometry_exp_group)
self.layout.addLayout(self.vlay)
self.layout.addWidget(self.geometry_adv_opt_group)
self.layout.addWidget(self.geometry_editor_group)

View File

@@ -1963,10 +1963,16 @@ class GeometryObject(FlatCAMObj, Geometry):
def export_dxf(self):
dwg = None
dxf_format = self.app.defaults['geometry_dxf_format']
try:
dwg = ezdxf.new('R2010')
dwg = ezdxf.new(dxf_format)
msp = dwg.modelspace()
# add units
dwg.units = ezdxf.InsertUnits(4) if self.app.defaults['units'].lower() == 'mm' else ezdxf.InsertUnits(1)
dwg.header['$MEASUREMENT'] = 1 if self.app.defaults['units'].lower() == 'mm' else 0
def g2dxf(dxf_space, geo_obj):
if isinstance(geo_obj, MultiPolygon):
for poly in geo_obj:

View File

@@ -748,10 +748,6 @@ class Geometry(object):
self.app.log.debug("camlib.Geometry.bounds()")
if self.solid_geometry is None:
self.app.log.debug("solid_geometry is None")
return 0, 0, 0, 0
def bounds_rec(obj):
if type(obj) is list:
gminx = np.Inf
@@ -805,8 +801,16 @@ class Geometry(object):
maxx_list.append(maxx)
maxy_list.append(maxy)
if not minx_list and not miny_list and not maxx_list and not maxy_list:
self.app.log.debug("solid_geometry is None")
return 0, 0, 0, 0
return min(minx_list), min(miny_list), max(maxx_list), max(maxy_list)
else:
if self.solid_geometry is None:
self.app.log.debug("solid_geometry is None")
return 0, 0, 0, 0
if flatten:
self.flatten(reset=True)
self.solid_geometry = self.flat_geometry

View File

@@ -304,6 +304,9 @@ class FlatCAMDefaults:
"geometry_segx": 0.0,
"geometry_segy": 0.0,
# Geometry Export
"geometry_dxf_format": 'R2010',
# Geometry Options
"tools_mill_tooldia": "2.4",
"tools_mill_offset_type": 0, # _('Path')