From fe1ea7b12ac9f12e680251d5cd1d3e00b8dc7eeb Mon Sep 17 00:00:00 2001 From: Marius Stanciu Date: Sun, 28 Feb 2021 01:03:13 +0200 Subject: [PATCH] - fixed Panelize Tool to work with objects made by merging other objects together --- CHANGELOG.md | 6 ++- appPlugins/ToolPanelize.py | 88 ++++++++++++++++++++------------------ 2 files changed, 52 insertions(+), 42 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c4d2dd81..7cb640a3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,11 @@ CHANGELOG for FlatCAM beta ================================================= -27.01.2021 +28.02.2021 + +- fixed Panelize Tool to work with objects made by merging other objects together + +27.02.2021 - added possibility of changing the Axis color and created a new parameter for that in Preferences - some refactoring diff --git a/appPlugins/ToolPanelize.py b/appPlugins/ToolPanelize.py index cf82f1c1..d27b9418 100644 --- a/appPlugins/ToolPanelize.py +++ b/appPlugins/ToolPanelize.py @@ -415,52 +415,58 @@ class Panelize(AppTool): old_disp_number = 0 for tool in panel_source_obj.tools: - if panel_source_obj.tools[tool]['drills']: - drill_nr = 0 - for drill in panel_source_obj.tools[tool]['drills']: - # graceful abort requested by the user - if self.app.abort_flag: - raise grace + if 'drills' in panel_source_obj.tools[tool]: + if panel_source_obj.tools[tool]['drills']: + drill_nr = 0 + for drill in panel_source_obj.tools[tool]['drills']: + # graceful abort requested by the user + if self.app.abort_flag: + raise grace - # offset / panelization - point_offseted = affinity.translate(drill, currentx, currenty) - obj_fin.tools[tool]['drills'].append(point_offseted) + # offset / panelization + point_offseted = affinity.translate(drill, currentx, currenty) + obj_fin.tools[tool]['drills'].append(point_offseted) - # update progress - drill_nr += 1 - disp_number = int(np.interp(drill_nr, [0, geo_len_drills], [0, 100])) - if old_disp_number < disp_number <= 100: - self.app.proc_container.update_view_text(' %s: %d D:%d%%' % - (_("Copy"), - int(element), - disp_number)) - old_disp_number = disp_number + # update progress + drill_nr += 1 + disp_number = int(np.interp(drill_nr, [0, geo_len_drills], [0, 100])) + if old_disp_number < disp_number <= 100: + self.app.proc_container.update_view_text(' %s: %d D:%d%%' % + (_("Copy"), + int(element), + disp_number)) + old_disp_number = disp_number + else: + panel_source_obj.tools[tool]['drills'] = [] - if panel_source_obj.tools[tool]['slots']: - slot_nr = 0 - for slot in panel_source_obj.tools[tool]['slots']: - # graceful abort requested by the user - if self.app.abort_flag: - raise grace + if 'slots' in panel_source_obj.tools[tool]: + if panel_source_obj.tools[tool]['slots']: + slot_nr = 0 + for slot in panel_source_obj.tools[tool]['slots']: + # graceful abort requested by the user + if self.app.abort_flag: + raise grace - # offset / panelization - start_offseted = affinity.translate(slot[0], currentx, currenty) - stop_offseted = affinity.translate(slot[1], currentx, currenty) - offseted_slot = ( - start_offseted, - stop_offseted - ) - obj_fin.tools[tool]['slots'].append(offseted_slot) + # offset / panelization + start_offseted = affinity.translate(slot[0], currentx, currenty) + stop_offseted = affinity.translate(slot[1], currentx, currenty) + offseted_slot = ( + start_offseted, + stop_offseted + ) + obj_fin.tools[tool]['slots'].append(offseted_slot) - # update progress - slot_nr += 1 - disp_number = int(np.interp(slot_nr, [0, geo_len_slots], [0, 100])) - if old_disp_number < disp_number <= 100: - self.app.proc_container.update_view_text(' %s: %d S:%d%%' % - (_("Copy"), - int(element), - disp_number)) - old_disp_number = disp_number + # update progress + slot_nr += 1 + disp_number = int(np.interp(slot_nr, [0, geo_len_slots], [0, 100])) + if old_disp_number < disp_number <= 100: + self.app.proc_container.update_view_text(' %s: %d S:%d%%' % + (_("Copy"), + int(element), + disp_number)) + old_disp_number = disp_number + else: + panel_source_obj.tools[tool]['slots'] = [] currentx += lenghtx currenty += lenghty