diff --git a/FlatCAMObj.py b/FlatCAMObj.py index 221c07b4..bbd61374 100644 --- a/FlatCAMObj.py +++ b/FlatCAMObj.py @@ -498,7 +498,7 @@ class FlatCAMGerber(FlatCAMObj, Gerber): sort = [] for k, v in list(self.aperture_macros.items()): - sort.append(int(k)) + sort.append(k) sorted_macros = sorted(sort) for ap_code in sorted_apertures: @@ -516,17 +516,25 @@ class FlatCAMGerber(FlatCAMObj, Gerber): if str(self.apertures[ap_code]['type']) == 'R' or str(self.apertures[ap_code]['type']) == 'O': ap_dim_item = QtWidgets.QTableWidgetItem( - '%.4f, %.4f' % (self.apertures[ap_code]['width'], self.apertures[ap_code]['height'])) + '%.4f, %.4f' % (self.apertures[ap_code]['width'] * self.file_units_factor, + self.apertures[ap_code]['height'] * self.file_units_factor + ) + ) ap_dim_item.setFlags(QtCore.Qt.ItemIsEnabled) elif str(self.apertures[ap_code]['type']) == 'P': ap_dim_item = QtWidgets.QTableWidgetItem( - '%.4f, %.4f' % (self.apertures[ap_code]['diam'], self.apertures[ap_code]['nVertices'])) + '%.4f, %.4f' % (self.apertures[ap_code]['diam'] * self.file_units_factor, + self.apertures[ap_code]['nVertices'] * self.file_units_factor) + ) ap_dim_item.setFlags(QtCore.Qt.ItemIsEnabled) else: ap_dim_item = QtWidgets.QTableWidgetItem('') ap_dim_item.setFlags(QtCore.Qt.ItemIsEnabled) - ap_size_item = QtWidgets.QTableWidgetItem('%.4f' % float(self.apertures[ap_code]['size'])) + if self.apertures[ap_code]['size'] is not None: + ap_size_item = QtWidgets.QTableWidgetItem('%.4f' % + float(self.apertures[ap_code]['size'] * + self.file_units_factor)) ap_size_item.setFlags(QtCore.Qt.ItemIsEnabled) plot_item = FCCheckBox() diff --git a/README.md b/README.md index b5364477..5a3a4396 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,7 @@ CAD program, and create G-Code for Isolation routing. - remade the Grids context menu (right mouse button click on canvas). Now it has values linked to the units type (inch or mm). Added ability to add or delete grid values and they are persistent. - updated the function for the project context menu 'Generate CNC' menu entry (Action) to use the modernized function FlatCAMObj.FlatCAMGeometry.on_generatecnc_button_click() - when linked, the grid snap on Y will copy the value in grid snap on X in real time +- in Gerber aperture table now the values are displayed in the current units set in FlatCAM 13.02.2019 diff --git a/camlib.py b/camlib.py index 48fad505..d161da65 100644 --- a/camlib.py +++ b/camlib.py @@ -98,6 +98,9 @@ class Geometry(object): # Flattened geometry (list of paths only) self.flat_geometry = [] + # this is the calculated conversion factor when the file units are different than the ones in the app + self.file_units_factor = 1 + # Index self.index = None @@ -1264,6 +1267,7 @@ class Geometry(object): self.units = units self.scale(factor) + self.file_units_factor = factor return factor def to_dict(self): @@ -1899,7 +1903,7 @@ class Gerber (Geometry): self.gerber_zeros = 'L' """Zeros in Gerber numbers. If 'L' then remove leading zeros, if 'T' remove trailing zeros. Used during parsing. """ - + ## Gerber elements ## # Apertures {'id':{'type':chr, # ['size':float], ['width':float],