From eb091f399089c86f740e94f82662df2cc4872c93 Mon Sep 17 00:00:00 2001 From: Marius Stanciu Date: Sun, 3 Nov 2019 13:19:48 +0200 Subject: [PATCH] - fixed a bug in SolderPaste Tool that did not allow to view the GCode --- FlatCAMApp.py | 3 + README.md | 5 + flatcamGUI/PreferencesUI.py | 120 ++++++++++++---------- flatcamTools/ToolCalculators.py | 3 +- flatcamTools/ToolNonCopperClear.py | 153 +++++++++++++++-------------- 5 files changed, 159 insertions(+), 125 deletions(-) diff --git a/FlatCAMApp.py b/FlatCAMApp.py index 22428809..c598bfda 100644 --- a/FlatCAMApp.py +++ b/FlatCAMApp.py @@ -729,6 +729,7 @@ class App(QtCore.QObject): "tools_ncccutz": self.ui.tools_defaults_form.tools_ncc_group.cutz_entry, "tools_ncctipdia": self.ui.tools_defaults_form.tools_ncc_group.tipdia_entry, "tools_ncctipangle": self.ui.tools_defaults_form.tools_ncc_group.tipangle_entry, + "tools_nccnewdia": self.ui.tools_defaults_form.tools_ncc_group.newdia_entry, # CutOut Tool "tools_cutouttooldia": self.ui.tools_defaults_form.tools_cutout_group.cutout_tooldia_entry, @@ -1205,6 +1206,7 @@ class App(QtCore.QObject): "tools_ncccutz": -0.001968504, "tools_ncctipdia": 0.00393701, "tools_ncctipangle": 30, + "tools_nccnewdia": 0.0393701, # Cutout Tool "tools_cutouttooldia": 0.0944882, @@ -5811,6 +5813,7 @@ class App(QtCore.QObject): 'tools_paintmargin', 'tools_painttooldia', 'tools_paintoverlap', "tools_ncctools", "tools_nccoverlap", "tools_nccmargin", "tools_ncccutz", "tools_ncctipdia", + "tools_nccnewdia", "tools_2sided_drilldia", "tools_film_boundary", "tools_cutouttooldia", 'tools_cutoutmargin', 'tools_cutoutgapsize', "tools_panelize_constrainx", "tools_panelize_constrainy", diff --git a/README.md b/README.md index 641a987b..d0c20cf6 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,11 @@ CAD program, and create G-Code for Isolation routing. ================================================= +3.11.2019 + +- fixed the V-shape tool diameter calculation in NCC Tool +- in NCC Tool made the new tool dia (circular type) a parameter in Preferences + 30.10.2019 - converted SolderPaste Tool to usage of SpinBoxes; changed the SolderPaste Tool UI in Preferences too diff --git a/flatcamGUI/PreferencesUI.py b/flatcamGUI/PreferencesUI.py index c87a4535..ec326c53 100644 --- a/flatcamGUI/PreferencesUI.py +++ b/flatcamGUI/PreferencesUI.py @@ -3712,6 +3712,7 @@ class ToolsNCCPrefGroupUI(OptionsGroupUI): super(ToolsNCCPrefGroupUI, self).__init__(self) self.setTitle(str(_("NCC Tool Options"))) + self.decimals = 4 # ## Clear non-copper regions self.clearcopper_label = QtWidgets.QLabel("%s:" % _("Parameters")) @@ -3756,7 +3757,7 @@ class ToolsNCCPrefGroupUI(OptionsGroupUI): self.tipdialabel.setToolTip( _("The tip diameter for V-Shape Tool")) self.tipdia_entry = FCDoubleSpinner() - self.tipdia_entry.set_precision(4) + self.tipdia_entry.set_precision(self.decimals) self.tipdia_entry.set_range(0, 1000) self.tipdia_entry.setSingleStep(0.1) @@ -3769,7 +3770,7 @@ class ToolsNCCPrefGroupUI(OptionsGroupUI): _("The tip angle for V-Shape Tool.\n" "In degree.")) self.tipangle_entry = FCDoubleSpinner() - self.tipangle_entry.set_precision(4) + self.tipangle_entry.set_precision(self.decimals) self.tipangle_entry.set_range(-360, 360) self.tipangle_entry.setSingleStep(5) self.tipangle_entry.setWrapping(True) @@ -3777,6 +3778,37 @@ class ToolsNCCPrefGroupUI(OptionsGroupUI): grid0.addWidget(self.tipanglelabel, 3, 0) grid0.addWidget(self.tipangle_entry, 3, 1) + # Cut Z entry + cutzlabel = QtWidgets.QLabel('%s:' % _('Cut Z')) + cutzlabel.setToolTip( + _("Depth of cut into material. Negative value.\n" + "In FlatCAM units.") + ) + self.cutz_entry = FCDoubleSpinner() + self.cutz_entry.set_precision(self.decimals) + self.cutz_entry.set_range(-9999.9999, -0.000001) + self.cutz_entry.setSingleStep(0.1) + + self.cutz_entry.setToolTip( + _("Depth of cut into material. Negative value.\n" + "In FlatCAM units.") + ) + + grid0.addWidget(cutzlabel, 4, 0) + grid0.addWidget(self.cutz_entry, 4, 1) + + # New Diameter + self.newdialabel = QtWidgets.QLabel('%s:' % _('New Tool Dia')) + self.newdialabel.setToolTip( + _("The new tool diameter (cut width) to add in the tool table.")) + self.newdia_entry = FCDoubleSpinner() + self.newdia_entry.set_precision(self.decimals) + self.newdia_entry.set_range(0.0001, 9999.9999) + self.newdia_entry.setSingleStep(0.1) + + grid0.addWidget(self.newdialabel, 5, 0) + grid0.addWidget(self.newdia_entry, 5, 1) + # Milling Type Radio Button self.milling_type_label = QtWidgets.QLabel('%s:' % _('Milling Type')) self.milling_type_label.setToolTip( @@ -3793,8 +3825,8 @@ class ToolsNCCPrefGroupUI(OptionsGroupUI): "- conventional / useful when there is no backlash compensation") ) - grid0.addWidget(self.milling_type_label, 4, 0) - grid0.addWidget(self.milling_type_radio, 4, 1) + grid0.addWidget(self.milling_type_label, 6, 0) + grid0.addWidget(self.milling_type_radio, 6, 1) # Tool order Radio Button self.ncc_order_label = QtWidgets.QLabel('%s:' % _('Tool order')) @@ -3814,27 +3846,8 @@ class ToolsNCCPrefGroupUI(OptionsGroupUI): "'Reverse' --> menas that the tools will ordered from big to small\n\n" "WARNING: using rest machining will automatically set the order\n" "in reverse and disable this control.")) - grid0.addWidget(self.ncc_order_label, 5, 0) - grid0.addWidget(self.ncc_order_radio, 5, 1) - - # Cut Z entry - cutzlabel = QtWidgets.QLabel('%s:' % _('Cut Z')) - cutzlabel.setToolTip( - _("Depth of cut into material. Negative value.\n" - "In FlatCAM units.") - ) - self.cutz_entry = FCDoubleSpinner() - self.cutz_entry.set_precision(4) - self.cutz_entry.set_range(-1000, -0.000001) - self.cutz_entry.setSingleStep(0.1) - - self.cutz_entry.setToolTip( - _("Depth of cut into material. Negative value.\n" - "In FlatCAM units.") - ) - - grid0.addWidget(cutzlabel, 6, 0) - grid0.addWidget(self.cutz_entry, 6, 1) + grid0.addWidget(self.ncc_order_label, 7, 0) + grid0.addWidget(self.ncc_order_radio, 7, 1) # Overlap Entry nccoverlabel = QtWidgets.QLabel('%s:' % _('Overlap Rate')) @@ -3850,25 +3863,25 @@ class ToolsNCCPrefGroupUI(OptionsGroupUI): "due of too many paths.") ) self.ncc_overlap_entry = FCDoubleSpinner() - self.ncc_overlap_entry.set_precision(3) + self.ncc_overlap_entry.set_precision(self.decimals) self.ncc_overlap_entry.setWrapping(True) self.ncc_overlap_entry.setRange(0.000, 0.999) self.ncc_overlap_entry.setSingleStep(0.1) - grid0.addWidget(nccoverlabel, 7, 0) - grid0.addWidget(self.ncc_overlap_entry, 7, 1) + grid0.addWidget(nccoverlabel, 8, 0) + grid0.addWidget(self.ncc_overlap_entry, 8, 1) # Margin entry nccmarginlabel = QtWidgets.QLabel('%s:' % _('Margin')) nccmarginlabel.setToolTip( _("Bounding box margin.") ) - grid0.addWidget(nccmarginlabel, 8, 0) self.ncc_margin_entry = FCDoubleSpinner() - self.ncc_margin_entry.set_precision(4) + self.ncc_margin_entry.set_precision(self.decimals) self.ncc_margin_entry.set_range(-10000, 10000) self.ncc_margin_entry.setSingleStep(0.1) - grid0.addWidget(self.ncc_margin_entry, 8, 1) + grid0.addWidget(nccmarginlabel, 9, 0) + grid0.addWidget(self.ncc_margin_entry, 9, 1) # Method methodlabel = QtWidgets.QLabel('%s:' % _('Method')) @@ -3878,13 +3891,15 @@ class ToolsNCCPrefGroupUI(OptionsGroupUI): "Seed-based: Outwards from seed.
" "Line-based: Parallel lines.") ) - grid0.addWidget(methodlabel, 9, 0) + self.ncc_method_radio = RadioSet([ {"label": _("Standard"), "value": "standard"}, {"label": _("Seed-based"), "value": "seed"}, {"label": _("Straight lines"), "value": "lines"} ], orientation='vertical', stretch=False) - grid0.addWidget(self.ncc_method_radio, 9, 1) + + grid0.addWidget(methodlabel, 10, 0) + grid0.addWidget(self.ncc_method_radio, 10, 1) # Connect lines pathconnectlabel = QtWidgets.QLabel('%s:' % _("Connect")) @@ -3892,9 +3907,10 @@ class ToolsNCCPrefGroupUI(OptionsGroupUI): _("Draw lines between resulting\n" "segments to minimize tool lifts.") ) - grid0.addWidget(pathconnectlabel, 10, 0) self.ncc_connect_cb = FCCheckBox() - grid0.addWidget(self.ncc_connect_cb, 10, 1) + + grid0.addWidget(pathconnectlabel, 11, 0) + grid0.addWidget(self.ncc_connect_cb, 11, 1) # Contour Checkbox contourlabel = QtWidgets.QLabel('%s:' % _("Contour")) @@ -3902,9 +3918,10 @@ class ToolsNCCPrefGroupUI(OptionsGroupUI): _("Cut around the perimeter of the polygon\n" "to trim rough edges.") ) - grid0.addWidget(contourlabel, 11, 0) self.ncc_contour_cb = FCCheckBox() - grid0.addWidget(self.ncc_contour_cb, 11, 1) + + grid0.addWidget(contourlabel, 12, 0) + grid0.addWidget(self.ncc_contour_cb, 12, 1) # Rest machining CheckBox restlabel = QtWidgets.QLabel('%s:' % _("Rest M.")) @@ -3917,9 +3934,10 @@ class ToolsNCCPrefGroupUI(OptionsGroupUI): "no more copper to clear or there are no more tools.\n" "If not checked, use the standard algorithm.") ) - grid0.addWidget(restlabel, 12, 0) self.ncc_rest_cb = FCCheckBox() - grid0.addWidget(self.ncc_rest_cb, 12, 1) + + grid0.addWidget(restlabel, 13, 0) + grid0.addWidget(self.ncc_rest_cb, 13, 1) # ## NCC Offset choice self.ncc_offset_choice_label = QtWidgets.QLabel('%s:' % _("Offset")) @@ -3929,9 +3947,10 @@ class ToolsNCCPrefGroupUI(OptionsGroupUI): "from the copper features.\n" "The value can be between 0 and 10 FlatCAM units.") ) - grid0.addWidget(self.ncc_offset_choice_label, 13, 0) self.ncc_choice_offset_cb = FCCheckBox() - grid0.addWidget(self.ncc_choice_offset_cb, 13, 1) + + grid0.addWidget(self.ncc_offset_choice_label, 14, 0) + grid0.addWidget(self.ncc_choice_offset_cb, 14, 1) # ## NCC Offset value self.ncc_offset_label = QtWidgets.QLabel('%s:' % _("Offset value")) @@ -3939,16 +3958,16 @@ class ToolsNCCPrefGroupUI(OptionsGroupUI): _("If used, it will add an offset to the copper features.\n" "The copper clearing will finish to a distance\n" "from the copper features.\n" - "The value can be between 0 and 10 FlatCAM units.") + "The value can be between 0.0 and 9999.9 FlatCAM units.") ) - grid0.addWidget(self.ncc_offset_label, 14, 0) self.ncc_offset_spinner = FCDoubleSpinner() - self.ncc_offset_spinner.set_range(0.00, 10.00) - self.ncc_offset_spinner.set_precision(4) + self.ncc_offset_spinner.set_range(0.00, 9999.9999) + self.ncc_offset_spinner.set_precision(self.decimals) self.ncc_offset_spinner.setWrapping(True) self.ncc_offset_spinner.setSingleStep(0.1) - grid0.addWidget(self.ncc_offset_spinner, 14, 1) + grid0.addWidget(self.ncc_offset_label, 15, 0) + grid0.addWidget(self.ncc_offset_spinner, 15, 1) # ## Reference self.reference_radio = RadioSet([{'label': _('Itself'), 'value': 'itself'}, @@ -3963,8 +3982,9 @@ class ToolsNCCPrefGroupUI(OptionsGroupUI): "- 'Reference Object' - will do non copper clearing within the area\n" "specified by another object.") ) - grid0.addWidget(reference_label, 15, 0) - grid0.addWidget(self.reference_radio, 15, 1) + + grid0.addWidget(reference_label, 16, 0) + grid0.addWidget(self.reference_radio, 16, 1) # ## Plotting type self.ncc_plotting_radio = RadioSet([{'label': _('Normal'), 'value': 'normal'}, @@ -3974,8 +3994,8 @@ class ToolsNCCPrefGroupUI(OptionsGroupUI): _("- 'Normal' - normal plotting, done at the end of the NCC job\n" "- 'Progressive' - after each shape is generated it will be plotted.") ) - grid0.addWidget(plotting_label, 16, 0) - grid0.addWidget(self.ncc_plotting_radio, 16, 1) + grid0.addWidget(plotting_label, 17, 0) + grid0.addWidget(self.ncc_plotting_radio, 17, 1) self.layout.addStretch() diff --git a/flatcamTools/ToolCalculators.py b/flatcamTools/ToolCalculators.py index 032ef5a7..6a43a3aa 100644 --- a/flatcamTools/ToolCalculators.py +++ b/flatcamTools/ToolCalculators.py @@ -325,8 +325,7 @@ class ToolCalculator(FlatCAMTool): tip_diameter = float(self.tipDia_entry.get_value()) - half_tip_angle = float(self.tipAngle_entry.get_value()) - half_tip_angle /= 2 + half_tip_angle = float(self.tipAngle_entry.get_value()) / 2.0 cut_depth = float(self.cutDepth_entry.get_value()) cut_depth = -cut_depth if cut_depth < 0 else cut_depth diff --git a/flatcamTools/ToolNonCopperClear.py b/flatcamTools/ToolNonCopperClear.py index b29203e3..835eb926 100644 --- a/flatcamTools/ToolNonCopperClear.py +++ b/flatcamTools/ToolNonCopperClear.py @@ -153,8 +153,10 @@ class NonCopperClear(FlatCAMTool, Gerber): "If it's not successful then the non-copper clearing will fail, too.\n" "- Clear -> the regular non-copper clearing.")) - form = QtWidgets.QFormLayout() - self.tools_box.addLayout(form) + grid1 = QtWidgets.QGridLayout() + self.tools_box.addLayout(grid1) + grid1.setColumnStretch(0, 0) + grid1.setColumnStretch(1, 1) # Milling Type Radio Button self.milling_type_label = QtWidgets.QLabel('%s:' % _('Milling Type')) @@ -172,6 +174,9 @@ class NonCopperClear(FlatCAMTool, Gerber): "- conventional / useful when there is no backlash compensation") ) + grid1.addWidget(self.milling_type_label, 0, 0) + grid1.addWidget(self.milling_type_radio, 0, 1) + # Tool order self.ncc_order_label = QtWidgets.QLabel('%s:' % _('Tool order')) self.ncc_order_label.setToolTip(_("This set the way that the tools in the tools table are used.\n" @@ -191,9 +196,9 @@ class NonCopperClear(FlatCAMTool, Gerber): "WARNING: using rest machining will automatically set the order\n" "in reverse and disable this control.")) - form.addRow(self.milling_type_label, self.milling_type_radio) - form.addRow(self.ncc_order_label, self.ncc_order_radio) - form.addRow(QtWidgets.QLabel('')) + grid1.addWidget(self.ncc_order_label, 1, 0) + grid1.addWidget(self.ncc_order_radio, 1, 1) + grid1.addWidget(QtWidgets.QLabel(''), 2, 0) self.milling_type_label.hide() self.milling_type_radio.hide() @@ -202,7 +207,7 @@ class NonCopperClear(FlatCAMTool, Gerber): # ############### Tool selection ############################## # ############################################################# self.tool_sel_label = QtWidgets.QLabel('%s' % _("Tool Selection")) - form.addRow(self.tool_sel_label) + grid1.addWidget(self.tool_sel_label, 3, 0, 1, 2) # Tool Type Radio Button self.tool_type_label = QtWidgets.QLabel('%s:' % _('Tool Type')) @@ -219,17 +224,8 @@ class NonCopperClear(FlatCAMTool, Gerber): "- 'V-shape'\n" "- Circular") ) - form.addRow(self.tool_type_label, self.tool_type_radio) - - # ### Add a new Tool #### - self.addtool_entry_lbl = QtWidgets.QLabel('%s:' % _('Tool Dia')) - self.addtool_entry_lbl.setToolTip( - _("Diameter for the new tool to add in the Tool Table") - ) - self.addtool_entry = FCDoubleSpinner() - self.addtool_entry.set_precision(self.decimals) - - form.addRow(self.addtool_entry_lbl, self.addtool_entry) + grid1.addWidget(self.tool_type_label, 4, 0) + grid1.addWidget(self.tool_type_radio, 4, 1) # Tip Dia self.tipdialabel = QtWidgets.QLabel('%s:' % _('V-Tip Dia')) @@ -239,7 +235,8 @@ class NonCopperClear(FlatCAMTool, Gerber): self.tipdia_entry.set_precision(self.decimals) self.tipdia_entry.setSingleStep(0.1) - form.addRow(self.tipdialabel, self.tipdia_entry) + grid1.addWidget(self.tipdialabel, 5, 0) + grid1.addWidget(self.tipdia_entry, 5, 1) # Tip Angle self.tipanglelabel = QtWidgets.QLabel('%s:' % _('V-Tip Angle')) @@ -250,7 +247,38 @@ class NonCopperClear(FlatCAMTool, Gerber): self.tipangle_entry.set_precision(self.decimals) self.tipangle_entry.setSingleStep(5) - form.addRow(self.tipanglelabel, self.tipangle_entry) + grid1.addWidget(self.tipanglelabel, 6, 0) + grid1.addWidget(self.tipangle_entry, 6 , 1) + + # Cut Z entry + cutzlabel = QtWidgets.QLabel('%s:' % _('Cut Z')) + cutzlabel.setToolTip( + _("Depth of cut into material. Negative value.\n" + "In FlatCAM units.") + ) + self.cutz_entry = FCDoubleSpinner() + self.cutz_entry.set_precision(self.decimals) + self.cutz_entry.set_range(-99999, -0.00000000000001) + + self.cutz_entry.setToolTip( + _("Depth of cut into material. Negative value.\n" + "In FlatCAM units.") + ) + grid1.addWidget(cutzlabel, 7, 0) + grid1.addWidget(self.cutz_entry, 7, 1) + + # ### Tool Diameter #### + self.addtool_entry_lbl = QtWidgets.QLabel('%s:' % _('Tool Dia')) + self.addtool_entry_lbl.setToolTip( + _("Diameter for the new tool to add in the Tool Table.\n" + "If the tool is V-shape type then this value is automatically\n" + "calculated from the other parameters.") + ) + self.addtool_entry = FCDoubleSpinner() + self.addtool_entry.set_precision(self.decimals) + + grid1.addWidget(self.addtool_entry_lbl, 8, 0) + grid1.addWidget(self.addtool_entry, 8, 1) grid2 = QtWidgets.QGridLayout() self.tools_box.addLayout(grid2) @@ -287,23 +315,6 @@ class NonCopperClear(FlatCAMTool, Gerber): e_lab_1 = QtWidgets.QLabel('%s:' % _("Parameters")) grid3.addWidget(e_lab_1, 0, 0) - # Cut Z entry - cutzlabel = QtWidgets.QLabel('%s:' % _('Cut Z')) - cutzlabel.setToolTip( - _("Depth of cut into material. Negative value.\n" - "In FlatCAM units.") - ) - self.cutz_entry = FCDoubleSpinner() - self.cutz_entry.set_precision(self.decimals) - self.cutz_entry.set_range(-99999, -0.00000000000001) - - self.cutz_entry.setToolTip( - _("Depth of cut into material. Negative value.\n" - "In FlatCAM units.") - ) - grid3.addWidget(cutzlabel, 1, 0) - grid3.addWidget(self.cutz_entry, 1, 1) - # Overlap Entry nccoverlabel = QtWidgets.QLabel('%s:' % _('Overlap Rate')) nccoverlabel.setToolTip( @@ -535,6 +546,10 @@ class NonCopperClear(FlatCAMTool, Gerber): self.deltool_btn.clicked.connect(self.on_tool_delete) self.generate_ncc_button.clicked.connect(self.on_ncc_click) + self.tipdia_entry.returnPressed.connect(self.on_calculate_tooldia) + self.tipangle_entry.returnPressed.connect(self.on_calculate_tooldia) + self.cutz_entry.returnPressed.connect(self.on_calculate_tooldia) + self.box_combo_type.currentIndexChanged.connect(self.on_combo_box_type) self.reference_radio.group_toggle_fn = self.on_toggle_reference self.ncc_choice_offset_cb.stateChanged.connect(self.on_offset_choice) @@ -551,7 +566,7 @@ class NonCopperClear(FlatCAMTool, Gerber): def on_add_tool_by_key(self): tool_add_popup = FCInputDialog(title='%s...' % _("New Tool"), text='%s:' % _('Enter a Tool Diameter'), - min=0.0000, max=99.9999, decimals=4) + min=0.0001, max=9999.9999, decimals=self.decimals) tool_add_popup.setWindowIcon(QtGui.QIcon('share/letter_t_32.png')) val, ok = tool_add_popup.get_value() @@ -624,6 +639,7 @@ class NonCopperClear(FlatCAMTool, Gerber): self.tool_type_radio.set_value(self.app.defaults["tools_ncctool_type"]) self.tipdia_entry.set_value(self.app.defaults["tools_ncctipdia"]) self.tipangle_entry.set_value(self.app.defaults["tools_ncctipangle"]) + self.addtool_entry.set_value(self.app.defaults["tools_nccnewdia"]) self.on_tool_type(val=self.tool_type_radio.get_value()) @@ -707,11 +723,6 @@ class NonCopperClear(FlatCAMTool, Gerber): # updated units self.units = self.app.ui.general_defaults_form.general_app_group.units_radio.get_value().upper() - if self.units == "IN": - self.addtool_entry.set_value(0.039) - else: - self.addtool_entry.set_value(1) - sorted_tools = [] for k, v in self.ncc_tools.items(): if self.units == "IN": @@ -905,54 +916,50 @@ class NonCopperClear(FlatCAMTool, Gerber): def on_tool_type(self, val): if val == 'V': - self.addtool_entry_lbl.hide() - self.addtool_entry.hide() + self.addtool_entry_lbl.setDisabled(True) + self.addtool_entry.setDisabled(True) self.tipdialabel.show() self.tipdia_entry.show() self.tipanglelabel.show() self.tipangle_entry.show() else: - self.addtool_entry_lbl.show() - self.addtool_entry.show() + self.addtool_entry_lbl.setDisabled(False) + self.addtool_entry.setDisabled(False) self.tipdialabel.hide() self.tipdia_entry.hide() self.tipanglelabel.hide() self.tipangle_entry.hide() + def on_calculate_tooldia(self): + if self.tool_type_radio.get_value() == 'V': + tip_dia = float(self.tipdia_entry.get_value()) + tip_angle = float(self.tipangle_entry.get_value()) / 2.0 + cut_z = float(self.cutz_entry.get_value()) + cut_z = -cut_z if cut_z < 0 else cut_z + + # calculated tool diameter so the cut_z parameter is obeyed + tool_dia = tip_dia + (2 * cut_z * math.tan(math.radians(tip_angle))) + + # update the default_data so it is used in the ncc_tools dict + self.default_data.update({ + "vtipdia": tip_dia, + "vtipangle": (tip_angle * 2), + }) + + self.addtool_entry.set_value(tool_dia) + + return tool_dia + else: + return float(self.addtool_entry.get_value()) + def on_tool_add(self, dia=None, muted=None): - self.ui_disconnect() - self.units = self.app.ui.general_defaults_form.general_app_group.units_radio.get_value().upper() if dia: tool_dia = dia else: - if self.tool_type_radio.get_value() == 'V': - - tip_dia = float(self.tipdia_entry.get_value()) - tip_angle = float(self.tipangle_entry.get_value()) / 2 - cut_z = float(self.cutz_entry.get_value()) - - # calculated tool diameter so the cut_z parameter is obeyed - tool_dia = tip_dia + 2 * cut_z * math.tan(math.radians(tip_angle)) - - # update the default_data so it is used in the ncc_tools dict - self.default_data.update({ - "vtipdia": tip_dia, - "vtipangle": (tip_angle * 2), - }) - else: - try: - tool_dia = float(self.addtool_entry.get_value()) - except ValueError: - # try to convert comma to decimal point. if it's still not working error message and return - try: - tool_dia = float(self.addtool_entry.get_value().replace(',', '.')) - except ValueError: - self.app.inform.emit('[ERROR_NOTCL] %s' % _("Wrong value format entered, use a number.")) - return - + tool_dia = self.on_calculate_tooldia() if tool_dia is None: self.build_ui() self.app.inform.emit('[WARNING_NOTCL] %s' % _("Please enter a tool diameter to add, in Float format."))