From d0e5b6c83a431c2e91e433dca09de4f83ccab187 Mon Sep 17 00:00:00 2001 From: Marius Stanciu Date: Fri, 25 Oct 2019 02:10:52 +0300 Subject: [PATCH] - fixed imports in all TclCommands --- README.md | 5 +++-- tclCommands/TclCommandAddCircle.py | 4 ++-- tclCommands/TclCommandAddPolygon.py | 2 +- tclCommands/TclCommandAddPolyline.py | 3 ++- tclCommands/TclCommandAddRectangle.py | 4 ++-- tclCommands/TclCommandAlignDrill.py | 6 +++++- tclCommands/TclCommandAlignDrillGrid.py | 3 ++- tclCommands/TclCommandBbox.py | 6 +++++- tclCommands/TclCommandBounds.py | 6 +++--- tclCommands/TclCommandClearShell.py | 2 +- tclCommands/TclCommandCncjob.py | 5 ++++- tclCommands/TclCommandCopperClear.py | 6 +++++- tclCommands/TclCommandCutout.py | 7 +++++- tclCommands/TclCommandDelete.py | 3 ++- tclCommands/TclCommandDrillcncjob.py | 7 ++++-- tclCommands/TclCommandExportGcode.py | 4 +++- tclCommands/TclCommandExportSVG.py | 5 ++--- tclCommands/TclCommandExteriors.py | 4 +++- tclCommands/TclCommandFollow.py | 4 +++- tclCommands/TclCommandGeoCutout.py | 7 +++++- tclCommands/TclCommandGeoUnion.py | 5 +++-- tclCommands/TclCommandGetNames.py | 3 ++- tclCommands/TclCommandGetSys.py | 4 ++-- tclCommands/TclCommandImportSvg.py | 5 +++-- tclCommands/TclCommandInteriors.py | 4 +++- tclCommands/TclCommandIsolate.py | 11 +++++----- tclCommands/TclCommandJoinExcellon.py | 4 +++- tclCommands/TclCommandJoinGeometry.py | 4 +++- tclCommands/TclCommandMillDrills.py | 6 ++++-- tclCommands/TclCommandMillSlots.py | 5 ++++- tclCommands/TclCommandMirror.py | 8 ++++--- tclCommands/TclCommandNew.py | 3 ++- tclCommands/TclCommandNewExcellon.py | 3 ++- tclCommands/TclCommandNewGeometry.py | 3 ++- tclCommands/TclCommandNewGerber.py | 5 +++-- tclCommands/TclCommandNregions.py | 7 +++++- tclCommands/TclCommandOffset.py | 3 ++- tclCommands/TclCommandOpenExcellon.py | 3 ++- tclCommands/TclCommandOpenGCode.py | 3 ++- tclCommands/TclCommandOpenGerber.py | 4 +++- tclCommands/TclCommandOpenProject.py | 3 ++- tclCommands/TclCommandOptions.py | 3 ++- tclCommands/TclCommandPaint.py | 6 +++++- tclCommands/TclCommandPanelize.py | 25 ++++++++++++++-------- tclCommands/TclCommandPlotAll.py | 3 ++- tclCommands/TclCommandPlotObjects.py | 3 ++- tclCommands/TclCommandQuit.py | 4 ++-- tclCommands/TclCommandSaveProject.py | 3 ++- tclCommands/TclCommandScale.py | 14 +++++++++++- tclCommands/TclCommandSetActive.py | 3 ++- tclCommands/TclCommandSetOrigin.py | 6 +++++- tclCommands/TclCommandSetSys.py | 3 ++- tclCommands/TclCommandSkew.py | 3 ++- tclCommands/TclCommandSubtractPoly.py | 9 +++++--- tclCommands/TclCommandSubtractRectangle.py | 13 +++++++++-- tclCommands/TclCommandVersion.py | 4 ++-- tclCommands/TclCommandWriteGCode.py | 5 +++-- 57 files changed, 206 insertions(+), 90 deletions(-) diff --git a/README.md b/README.md index 8896afde..36451d55 100644 --- a/README.md +++ b/README.md @@ -14,13 +14,14 @@ CAD program, and create G-Code for Isolation routing. - QRCode Tool: added ability to add negative QRCodes (perhaps they can be isolated on copper?); added a clear area surrounding the QRCode in case it is dropped on a copper pour (region); fixed the Gerber export - QRCode Tool: all parameters are hard-coded for now - small update +- fixed imports in all TclCommands 24.10.2019 - added some placeholder texts in the TextBoxes. -- working on QRCode Tool; added the utility geometry and intial functional layout +- working on QRCode Tool; added the utility geometry and initial functional layout - working on QRCode Tool; finished adding the QRCode geometry to the selected Gerber object and also finished adding the 'follow' geometry needed when exporting the Gerber object as a Gerber file in addition to the 'solid' geometry in the obj.apertures -- working on QRCode Tool; finished offseting the geometry both in apertures and in solid_geometry; updated the source_file of the source object +- working on QRCode Tool; finished offsetting the geometry both in apertures and in solid_geometry; updated the source_file of the source object 23.10.2019 diff --git a/tclCommands/TclCommandAddCircle.py b/tclCommands/TclCommandAddCircle.py index a83777fa..c5d6776f 100644 --- a/tclCommands/TclCommandAddCircle.py +++ b/tclCommands/TclCommandAddCircle.py @@ -1,4 +1,4 @@ -from ObjectCollection import * +import collections from tclCommands.TclCommand import TclCommand @@ -56,7 +56,7 @@ class TclCommandAddCircle(TclCommand): try: obj = self.app.collection.get_by_name(str(obj_name)) - except: + except Exception as e: return "Could not retrieve object: %s" % obj_name if obj is None: return "Object not found: %s" % obj_name diff --git a/tclCommands/TclCommandAddPolygon.py b/tclCommands/TclCommandAddPolygon.py index 5ea73034..08ec3798 100644 --- a/tclCommands/TclCommandAddPolygon.py +++ b/tclCommands/TclCommandAddPolygon.py @@ -1,4 +1,4 @@ -from ObjectCollection import * +from camlib import Geometry from tclCommands.TclCommand import * diff --git a/tclCommands/TclCommandAddPolyline.py b/tclCommands/TclCommandAddPolyline.py index be897181..b7c0a47b 100644 --- a/tclCommands/TclCommandAddPolyline.py +++ b/tclCommands/TclCommandAddPolyline.py @@ -1,4 +1,5 @@ -from ObjectCollection import * +from camlib import Geometry +import collections from tclCommands.TclCommand import TclCommandSignaled diff --git a/tclCommands/TclCommandAddRectangle.py b/tclCommands/TclCommandAddRectangle.py index 7b1e6b9f..e41179c8 100644 --- a/tclCommands/TclCommandAddRectangle.py +++ b/tclCommands/TclCommandAddRectangle.py @@ -1,4 +1,4 @@ -from ObjectCollection import * +import collections from tclCommands.TclCommand import TclCommandSignaled @@ -58,7 +58,7 @@ class TclCommandAddRectangle(TclCommandSignaled): try: obj = self.app.collection.get_by_name(str(obj_name)) - except: + except Exception as e: return "Could not retrieve object: %s" % obj_name if obj is None: return "Object not found: %s" % obj_name diff --git a/tclCommands/TclCommandAlignDrill.py b/tclCommands/TclCommandAlignDrill.py index 7ce59b2a..55d5abd1 100644 --- a/tclCommands/TclCommandAlignDrill.py +++ b/tclCommands/TclCommandAlignDrill.py @@ -1,5 +1,9 @@ -from ObjectCollection import * +import collections from tclCommands.TclCommand import TclCommandSignaled +from FlatCAMObj import FlatCAMGeometry, FlatCAMGerber, FlatCAMExcellon + +from shapely.geometry import Point +import shapely.affinity as affinity class TclCommandAlignDrill(TclCommandSignaled): diff --git a/tclCommands/TclCommandAlignDrillGrid.py b/tclCommands/TclCommandAlignDrillGrid.py index bdfa014d..e15bd840 100644 --- a/tclCommands/TclCommandAlignDrillGrid.py +++ b/tclCommands/TclCommandAlignDrillGrid.py @@ -1,6 +1,7 @@ -from ObjectCollection import * +import collections from tclCommands.TclCommand import TclCommandSignaled +from shapely.geometry import Point class TclCommandAlignDrillGrid(TclCommandSignaled): """ diff --git a/tclCommands/TclCommandBbox.py b/tclCommands/TclCommandBbox.py index d1ecd954..ba9ca2fc 100644 --- a/tclCommands/TclCommandBbox.py +++ b/tclCommands/TclCommandBbox.py @@ -1,5 +1,9 @@ -from ObjectCollection import * +import collections from tclCommands.TclCommand import TclCommand +from FlatCAMObj import FlatCAMGeometry, FlatCAMGerber + +from shapely.ops import cascaded_union + import gettext import FlatCAMTranslation as fcTranslate import builtins diff --git a/tclCommands/TclCommandBounds.py b/tclCommands/TclCommandBounds.py index 9f50f52c..6736f458 100644 --- a/tclCommands/TclCommandBounds.py +++ b/tclCommands/TclCommandBounds.py @@ -1,7 +1,6 @@ from tclCommands.TclCommand import TclCommand -from ObjectCollection import * - -from camlib import get_bounds +import collections +import logging import gettext import FlatCAMTranslation as fcTranslate @@ -11,6 +10,7 @@ fcTranslate.apply_language('strings') if '_' not in builtins.__dict__: _ = gettext.gettext +log = logging.getLogger('base') class TclCommandBounds(TclCommand): """ diff --git a/tclCommands/TclCommandClearShell.py b/tclCommands/TclCommandClearShell.py index 97d9ebe2..d765367a 100644 --- a/tclCommands/TclCommandClearShell.py +++ b/tclCommands/TclCommandClearShell.py @@ -6,7 +6,7 @@ # ########################################################## from tclCommands.TclCommand import TclCommand -from ObjectCollection import * +import collections class TclCommandClearShell(TclCommand): diff --git a/tclCommands/TclCommandCncjob.py b/tclCommands/TclCommandCncjob.py index 74778c26..cc6b99a4 100644 --- a/tclCommands/TclCommandCncjob.py +++ b/tclCommands/TclCommandCncjob.py @@ -1,5 +1,8 @@ -from ObjectCollection import * from tclCommands.TclCommand import TclCommandSignaled +from FlatCAMObj import FlatCAMGeometry + +import collections +from copy import deepcopy class TclCommandCncjob(TclCommandSignaled): diff --git a/tclCommands/TclCommandCopperClear.py b/tclCommands/TclCommandCopperClear.py index 0f93169e..4ead909d 100644 --- a/tclCommands/TclCommandCopperClear.py +++ b/tclCommands/TclCommandCopperClear.py @@ -1,6 +1,8 @@ -from ObjectCollection import * from tclCommands.TclCommand import TclCommand +import collections +import logging + import gettext import FlatCAMTranslation as fcTranslate import builtins @@ -9,6 +11,8 @@ fcTranslate.apply_language('strings') if '_' not in builtins.__dict__: _ = gettext.gettext +log = logging.getLogger('base') + class TclCommandCopperClear(TclCommand): """ diff --git a/tclCommands/TclCommandCutout.py b/tclCommands/TclCommandCutout.py index 782d174b..6c973e00 100644 --- a/tclCommands/TclCommandCutout.py +++ b/tclCommands/TclCommandCutout.py @@ -1,8 +1,13 @@ -from ObjectCollection import * from tclCommands.TclCommand import TclCommand + +import collections +import logging + from shapely.ops import cascaded_union from shapely.geometry import LineString +log = logging.getLogger('base') + class TclCommandCutout(TclCommand): """ diff --git a/tclCommands/TclCommandDelete.py b/tclCommands/TclCommandDelete.py index 455dfe60..c5deb08d 100644 --- a/tclCommands/TclCommandDelete.py +++ b/tclCommands/TclCommandDelete.py @@ -1,6 +1,7 @@ -from ObjectCollection import * from tclCommands.TclCommand import TclCommand +import collections + class TclCommandDelete(TclCommand): """ diff --git a/tclCommands/TclCommandDrillcncjob.py b/tclCommands/TclCommandDrillcncjob.py index d50d0008..23eb8fd0 100644 --- a/tclCommands/TclCommandDrillcncjob.py +++ b/tclCommands/TclCommandDrillcncjob.py @@ -1,5 +1,8 @@ -from ObjectCollection import * from tclCommands.TclCommand import TclCommandSignaled +from FlatCAMObj import FlatCAMExcellon + +import collections +import math class TclCommandDrillcncjob(TclCommandSignaled): @@ -114,7 +117,7 @@ class TclCommandDrillcncjob(TclCommandSignaled): try: if 'drilled_dias' in args and args['drilled_dias'] != 'all': - diameters = [x.strip() for x in args['drilled_dias'].split(",") if x!= ''] + diameters = [x.strip() for x in args['drilled_dias'].split(",") if x != ''] nr_diameters = len(diameters) req_tools = set() diff --git a/tclCommands/TclCommandExportGcode.py b/tclCommands/TclCommandExportGcode.py index 84d0b676..23842c91 100644 --- a/tclCommands/TclCommandExportGcode.py +++ b/tclCommands/TclCommandExportGcode.py @@ -1,5 +1,7 @@ -from ObjectCollection import * from tclCommands.TclCommand import TclCommandSignaled +from camlib import CNCjob + +import collections class TclCommandExportGcode(TclCommandSignaled): diff --git a/tclCommands/TclCommandExportSVG.py b/tclCommands/TclCommandExportSVG.py index 4c4e6294..ebe95bc6 100644 --- a/tclCommands/TclCommandExportSVG.py +++ b/tclCommands/TclCommandExportSVG.py @@ -1,6 +1,7 @@ -from ObjectCollection import * from tclCommands.TclCommand import TclCommand +import collections + class TclCommandExportSVG(TclCommand): """ @@ -47,6 +48,4 @@ class TclCommandExportSVG(TclCommand): :return: """ - name = args['name'] - self.app.export_svg(**args) diff --git a/tclCommands/TclCommandExteriors.py b/tclCommands/TclCommandExteriors.py index c4737c3a..e6a65503 100644 --- a/tclCommands/TclCommandExteriors.py +++ b/tclCommands/TclCommandExteriors.py @@ -1,5 +1,7 @@ -from ObjectCollection import * from tclCommands.TclCommand import TclCommandSignaled +from camlib import Geometry + +import collections class TclCommandExteriors(TclCommandSignaled): diff --git a/tclCommands/TclCommandFollow.py b/tclCommands/TclCommandFollow.py index e9a5a905..59ad53ee 100644 --- a/tclCommands/TclCommandFollow.py +++ b/tclCommands/TclCommandFollow.py @@ -1,5 +1,7 @@ -from ObjectCollection import * from tclCommands.TclCommand import TclCommandSignaled +from FlatCAMObj import FlatCAMGerber + +import collections class TclCommandFollow(TclCommandSignaled): diff --git a/tclCommands/TclCommandGeoCutout.py b/tclCommands/TclCommandGeoCutout.py index 6e2bf86f..d317308e 100644 --- a/tclCommands/TclCommandGeoCutout.py +++ b/tclCommands/TclCommandGeoCutout.py @@ -1,9 +1,14 @@ -from ObjectCollection import * from tclCommands.TclCommand import TclCommandSignaled +from FlatCAMObj import FlatCAMGerber, FlatCAMGeometry + +import logging +import collections from copy import deepcopy from shapely.ops import cascaded_union from shapely.geometry import Polygon, LineString, LinearRing +log = logging.getLogger('base') + class TclCommandGeoCutout(TclCommandSignaled): """ diff --git a/tclCommands/TclCommandGeoUnion.py b/tclCommands/TclCommandGeoUnion.py index d0294e93..4e5e7c95 100644 --- a/tclCommands/TclCommandGeoUnion.py +++ b/tclCommands/TclCommandGeoUnion.py @@ -1,6 +1,7 @@ -from ObjectCollection import * from tclCommands.TclCommand import TclCommand +import collections + class TclCommandGeoUnion(TclCommand): """ @@ -50,7 +51,7 @@ class TclCommandGeoUnion(TclCommand): obj_name = args['name'] try: - obj = self.collection.get_by_name(str(obj_name)) + obj = self.app.collection.get_by_name(str(obj_name)) except: return "Could not retrieve object: %s" % obj_name if obj is None: diff --git a/tclCommands/TclCommandGetNames.py b/tclCommands/TclCommandGetNames.py index db4524f0..6b597f6f 100644 --- a/tclCommands/TclCommandGetNames.py +++ b/tclCommands/TclCommandGetNames.py @@ -1,6 +1,7 @@ -from ObjectCollection import * from tclCommands.TclCommand import TclCommand +import collections + class TclCommandGetNames(TclCommand): """ diff --git a/tclCommands/TclCommandGetSys.py b/tclCommands/TclCommandGetSys.py index b2864cdd..915ac18e 100644 --- a/tclCommands/TclCommandGetSys.py +++ b/tclCommands/TclCommandGetSys.py @@ -5,9 +5,10 @@ # MIT Licence # # ########################################################## -from ObjectCollection import * from tclCommands.TclCommand import TclCommand +import collections + class TclCommandGetSys(TclCommand): """ @@ -54,4 +55,3 @@ class TclCommandGetSys(TclCommand): if name in self.app.defaults: return self.app.defaults[name] - diff --git a/tclCommands/TclCommandImportSvg.py b/tclCommands/TclCommandImportSvg.py index 3edea7ef..6489db15 100644 --- a/tclCommands/TclCommandImportSvg.py +++ b/tclCommands/TclCommandImportSvg.py @@ -1,6 +1,8 @@ -from camlib import * from tclCommands.TclCommand import TclCommandSignaled +import collections +from camlib import Geometry + class TclCommandImportSvg(TclCommandSignaled): """ @@ -78,4 +80,3 @@ class TclCommandImportSvg(TclCommandSignaled): # GUI feedback self.app.inform.emit("Opened: " + filename) - diff --git a/tclCommands/TclCommandInteriors.py b/tclCommands/TclCommandInteriors.py index 401bc17a..d4a1adb3 100644 --- a/tclCommands/TclCommandInteriors.py +++ b/tclCommands/TclCommandInteriors.py @@ -1,5 +1,7 @@ -from ObjectCollection import * from tclCommands.TclCommand import TclCommandSignaled +from camlib import Geometry + +import collections class TclCommandInteriors(TclCommandSignaled): diff --git a/tclCommands/TclCommandIsolate.py b/tclCommands/TclCommandIsolate.py index eddf1527..75dd3fec 100644 --- a/tclCommands/TclCommandIsolate.py +++ b/tclCommands/TclCommandIsolate.py @@ -1,6 +1,7 @@ -from ObjectCollection import * from tclCommands.TclCommand import TclCommandSignaled +from FlatCAMObj import FlatCAMGerber +import collections class TclCommandIsolate(TclCommandSignaled): """ @@ -69,10 +70,10 @@ class TclCommandIsolate(TclCommandSignaled): if 'outname' not in args: args['outname'] = name + "_iso" - if 'timeout' in args: - timeout = args['timeout'] - else: - timeout = 10000 + # if 'timeout' in args: + # timeout = args['timeout'] + # else: + # timeout = 10000 if 'follow' not in args: args['follow'] = None diff --git a/tclCommands/TclCommandJoinExcellon.py b/tclCommands/TclCommandJoinExcellon.py index 60a371fc..efe6290e 100644 --- a/tclCommands/TclCommandJoinExcellon.py +++ b/tclCommands/TclCommandJoinExcellon.py @@ -1,5 +1,7 @@ -from ObjectCollection import * from tclCommands.TclCommand import TclCommand +from FlatCAMObj import FlatCAMExcellon + +import collections class TclCommandJoinExcellon(TclCommand): diff --git a/tclCommands/TclCommandJoinGeometry.py b/tclCommands/TclCommandJoinGeometry.py index 005a2e09..74036d80 100644 --- a/tclCommands/TclCommandJoinGeometry.py +++ b/tclCommands/TclCommandJoinGeometry.py @@ -1,5 +1,7 @@ -from ObjectCollection import * from tclCommands.TclCommand import TclCommand +from FlatCAMObj import FlatCAMGeometry + +import collections class TclCommandJoinGeometry(TclCommand): diff --git a/tclCommands/TclCommandMillDrills.py b/tclCommands/TclCommandMillDrills.py index 77084313..a9d5aaff 100644 --- a/tclCommands/TclCommandMillDrills.py +++ b/tclCommands/TclCommandMillDrills.py @@ -5,9 +5,11 @@ # MIT Licence # # ########################################################## -from ObjectCollection import * from tclCommands.TclCommand import TclCommandSignaled +from FlatCAMObj import FlatCAMExcellon +import math +import collections class TclCommandMillDrills(TclCommandSignaled): """ @@ -72,7 +74,7 @@ class TclCommandMillDrills(TclCommandSignaled): try: obj = self.app.collection.get_by_name(str(name)) - except: + except Exception as e: obj = None self.raise_tcl_error("Could not retrieve object: %s" % name) diff --git a/tclCommands/TclCommandMillSlots.py b/tclCommands/TclCommandMillSlots.py index 5f1ec37a..a18a9dbc 100644 --- a/tclCommands/TclCommandMillSlots.py +++ b/tclCommands/TclCommandMillSlots.py @@ -5,8 +5,11 @@ # MIT Licence # # ########################################################## -from ObjectCollection import * from tclCommands.TclCommand import TclCommandSignaled +from FlatCAMObj import FlatCAMExcellon + +import collections +import math class TclCommandMillSlots(TclCommandSignaled): diff --git a/tclCommands/TclCommandMirror.py b/tclCommands/TclCommandMirror.py index 821e91b3..de0fa021 100644 --- a/tclCommands/TclCommandMirror.py +++ b/tclCommands/TclCommandMirror.py @@ -1,5 +1,7 @@ -from ObjectCollection import * from tclCommands.TclCommand import TclCommandSignaled +from FlatCAMObj import FlatCAMExcellon, FlatCAMGeometry, FlatCAMGerber + +import collections class TclCommandMirror(TclCommandSignaled): @@ -55,7 +57,7 @@ class TclCommandMirror(TclCommandSignaled): # Get source object. try: obj = self.app.collection.get_by_name(str(name)) - except: + except Exception as e: return "Could not retrieve object: %s" % name if obj is None: @@ -76,7 +78,7 @@ class TclCommandMirror(TclCommandSignaled): if 'box' in args: try: box = self.app.collection.get_by_name(args['box']) - except: + except Exception as e: return "Could not retrieve object box: %s" % args['box'] if box is None: diff --git a/tclCommands/TclCommandNew.py b/tclCommands/TclCommandNew.py index 3ad7eb76..757412d3 100644 --- a/tclCommands/TclCommandNew.py +++ b/tclCommands/TclCommandNew.py @@ -1,6 +1,7 @@ -from ObjectCollection import * from tclCommands.TclCommand import TclCommand +import collections + class TclCommandNew(TclCommand): """ diff --git a/tclCommands/TclCommandNewExcellon.py b/tclCommands/TclCommandNewExcellon.py index c027869c..2c540fe1 100644 --- a/tclCommands/TclCommandNewExcellon.py +++ b/tclCommands/TclCommandNewExcellon.py @@ -5,9 +5,10 @@ # MIT Licence # # ########################################################## -from ObjectCollection import * from tclCommands.TclCommand import TclCommandSignaled +import collections + class TclCommandNewExcellon(TclCommandSignaled): """ diff --git a/tclCommands/TclCommandNewGeometry.py b/tclCommands/TclCommandNewGeometry.py index 746a8d85..089b2c50 100644 --- a/tclCommands/TclCommandNewGeometry.py +++ b/tclCommands/TclCommandNewGeometry.py @@ -1,6 +1,7 @@ -from ObjectCollection import * from tclCommands.TclCommand import TclCommandSignaled +import collections + class TclCommandNewGeometry(TclCommandSignaled): """ diff --git a/tclCommands/TclCommandNewGerber.py b/tclCommands/TclCommandNewGerber.py index fc1acc7e..bccbd923 100644 --- a/tclCommands/TclCommandNewGerber.py +++ b/tclCommands/TclCommandNewGerber.py @@ -5,9 +5,10 @@ # MIT Licence # # ########################################################## -from ObjectCollection import * from tclCommands.TclCommand import TclCommandSignaled +import collections + class TclCommandNewGerber(TclCommandSignaled): """ @@ -56,7 +57,7 @@ class TclCommandNewGerber(TclCommandSignaled): else: name = 'new_grb' - def initialize(grb_obj, self): + def initialize(grb_obj, app_obj): grb_obj.multitool = False grb_obj.source_file = [] grb_obj.multigeo = False diff --git a/tclCommands/TclCommandNregions.py b/tclCommands/TclCommandNregions.py index 34cd43b9..7bad21f7 100644 --- a/tclCommands/TclCommandNregions.py +++ b/tclCommands/TclCommandNregions.py @@ -1,5 +1,10 @@ -from ObjectCollection import * from tclCommands.TclCommand import TclCommand +from FlatCAMObj import FlatCAMGeometry, FlatCAMGerber + +from shapely.ops import cascaded_union + +import collections + import gettext import FlatCAMTranslation as fcTranslate import builtins diff --git a/tclCommands/TclCommandOffset.py b/tclCommands/TclCommandOffset.py index 7031c0db..cbdd976e 100644 --- a/tclCommands/TclCommandOffset.py +++ b/tclCommands/TclCommandOffset.py @@ -1,6 +1,7 @@ -from ObjectCollection import * from tclCommands.TclCommand import TclCommand +import collections + class TclCommandOffset(TclCommand): """ diff --git a/tclCommands/TclCommandOpenExcellon.py b/tclCommands/TclCommandOpenExcellon.py index cc4d7559..c9f32409 100644 --- a/tclCommands/TclCommandOpenExcellon.py +++ b/tclCommands/TclCommandOpenExcellon.py @@ -1,6 +1,7 @@ -from ObjectCollection import * from tclCommands.TclCommand import TclCommandSignaled +import collections + class TclCommandOpenExcellon(TclCommandSignaled): """ diff --git a/tclCommands/TclCommandOpenGCode.py b/tclCommands/TclCommandOpenGCode.py index 0542f6dc..d4da1423 100644 --- a/tclCommands/TclCommandOpenGCode.py +++ b/tclCommands/TclCommandOpenGCode.py @@ -1,6 +1,7 @@ -from ObjectCollection import * from tclCommands.TclCommand import TclCommandSignaled +import collections + class TclCommandOpenGCode(TclCommandSignaled): """ diff --git a/tclCommands/TclCommandOpenGerber.py b/tclCommands/TclCommandOpenGerber.py index 3ffbb221..d7543d4a 100644 --- a/tclCommands/TclCommandOpenGerber.py +++ b/tclCommands/TclCommandOpenGerber.py @@ -1,5 +1,7 @@ -from ObjectCollection import * from tclCommands.TclCommand import TclCommandSignaled +from camlib import Geometry, ParseError + +import collections class TclCommandOpenGerber(TclCommandSignaled): diff --git a/tclCommands/TclCommandOpenProject.py b/tclCommands/TclCommandOpenProject.py index eab891e9..ef0775af 100644 --- a/tclCommands/TclCommandOpenProject.py +++ b/tclCommands/TclCommandOpenProject.py @@ -1,6 +1,7 @@ -from ObjectCollection import * from tclCommands.TclCommand import TclCommandSignaled +import collections + class TclCommandOpenProject(TclCommandSignaled): """ diff --git a/tclCommands/TclCommandOptions.py b/tclCommands/TclCommandOptions.py index 443416cf..4bc90b84 100644 --- a/tclCommands/TclCommandOptions.py +++ b/tclCommands/TclCommandOptions.py @@ -1,6 +1,7 @@ -from ObjectCollection import * from tclCommands.TclCommand import TclCommandSignaled +import collections + class TclCommandOptions(TclCommandSignaled): """ diff --git a/tclCommands/TclCommandPaint.py b/tclCommands/TclCommandPaint.py index 4263b84c..5d55a6f9 100644 --- a/tclCommands/TclCommandPaint.py +++ b/tclCommands/TclCommandPaint.py @@ -1,6 +1,8 @@ -from ObjectCollection import * from tclCommands.TclCommand import TclCommand +import collections +import logging + import gettext import FlatCAMTranslation as fcTranslate import builtins @@ -9,6 +11,8 @@ fcTranslate.apply_language('strings') if '_' not in builtins.__dict__: _ = gettext.gettext +log = logging.getLogger('base') + class TclCommandPaint(TclCommand): """ diff --git a/tclCommands/TclCommandPanelize.py b/tclCommands/TclCommandPanelize.py index 3497ad0a..2d8c4460 100644 --- a/tclCommands/TclCommandPanelize.py +++ b/tclCommands/TclCommandPanelize.py @@ -1,7 +1,13 @@ -from ObjectCollection import * -from copy import copy,deepcopy - from tclCommands.TclCommand import TclCommand +from FlatCAMObj import FlatCAMGeometry, FlatCAMExcellon + +import shapely.affinity as affinity + +import logging +from copy import deepcopy +import collections + +log = logging.getLogger('base') class TclCommandPanelize(TclCommand): @@ -64,7 +70,7 @@ class TclCommandPanelize(TclCommand): # Get source object. try: obj = self.app.collection.get_by_name(str(name)) - except: + except Exception as e: return "Could not retrieve object: %s" % name if obj is None: @@ -74,7 +80,7 @@ class TclCommandPanelize(TclCommand): boxname = args['box'] try: box = self.app.collection.get_by_name(boxname) - except: + except Exception as e: return "Could not retrieve object: %s" % name else: box = obj @@ -185,8 +191,9 @@ class TclCommandPanelize(TclCommand): if option is not 'name': try: obj_fin.options[option] = obj.options[option] - except: - log.warning("Failed to copy option.", option) + except Exception as e: + log.warning("Failed to copy option: %s" % str(option)) + log.debug("TclCommandPanelize.execute().panelize2() --> %s" % str(e)) for row in range(rows): currentx = 0.0 @@ -277,9 +284,9 @@ class TclCommandPanelize(TclCommand): try: panelize_2() self.app.inform.emit("[success] Panel created successfully.") - except Exception as e: + except Exception as ee: proc.done() - log.debug(str(e)) + log.debug(str(ee)) return proc.done() diff --git a/tclCommands/TclCommandPlotAll.py b/tclCommands/TclCommandPlotAll.py index a2028907..2e8ead22 100644 --- a/tclCommands/TclCommandPlotAll.py +++ b/tclCommands/TclCommandPlotAll.py @@ -1,6 +1,7 @@ -from ObjectCollection import * from tclCommands.TclCommand import TclCommand +import collections + class TclCommandPlotAll(TclCommand): """ diff --git a/tclCommands/TclCommandPlotObjects.py b/tclCommands/TclCommandPlotObjects.py index 350c6552..bc3978a3 100644 --- a/tclCommands/TclCommandPlotObjects.py +++ b/tclCommands/TclCommandPlotObjects.py @@ -5,9 +5,10 @@ # MIT Licence # # ########################################################## -from ObjectCollection import * from tclCommands.TclCommand import TclCommand +import collections + class TclCommandPlotObjects(TclCommand): """ diff --git a/tclCommands/TclCommandQuit.py b/tclCommands/TclCommandQuit.py index 917c2f83..e0470bdb 100644 --- a/tclCommands/TclCommandQuit.py +++ b/tclCommands/TclCommandQuit.py @@ -5,9 +5,10 @@ # MIT Licence # # ########################################################## -from ObjectCollection import * from tclCommands.TclCommand import TclCommand +import collections + class TclCommandQuit(TclCommand): """ @@ -51,4 +52,3 @@ class TclCommandQuit(TclCommand): """ self.app.quit_application() - diff --git a/tclCommands/TclCommandSaveProject.py b/tclCommands/TclCommandSaveProject.py index 43bf73f3..9eaa1bbe 100644 --- a/tclCommands/TclCommandSaveProject.py +++ b/tclCommands/TclCommandSaveProject.py @@ -1,6 +1,7 @@ -from ObjectCollection import * from tclCommands.TclCommand import TclCommandSignaled +import collections + class TclCommandSaveProject(TclCommandSignaled): """ diff --git a/tclCommands/TclCommandScale.py b/tclCommands/TclCommandScale.py index 1fbe670b..8f68ee92 100644 --- a/tclCommands/TclCommandScale.py +++ b/tclCommands/TclCommandScale.py @@ -1,6 +1,18 @@ -from ObjectCollection import * from tclCommands.TclCommand import TclCommand +import collections +import logging + +import gettext +import FlatCAMTranslation as fcTranslate +import builtins + +fcTranslate.apply_language('strings') +if '_' not in builtins.__dict__: + _ = gettext.gettext + +log = logging.getLogger('base') + class TclCommandScale(TclCommand): """ diff --git a/tclCommands/TclCommandSetActive.py b/tclCommands/TclCommandSetActive.py index 21aee2bf..2c51b72c 100644 --- a/tclCommands/TclCommandSetActive.py +++ b/tclCommands/TclCommandSetActive.py @@ -1,6 +1,7 @@ -from ObjectCollection import * from tclCommands.TclCommand import TclCommand +import collections + class TclCommandSetActive(TclCommand): """ diff --git a/tclCommands/TclCommandSetOrigin.py b/tclCommands/TclCommandSetOrigin.py index 276fbe28..8e77bfab 100644 --- a/tclCommands/TclCommandSetOrigin.py +++ b/tclCommands/TclCommandSetOrigin.py @@ -6,10 +6,12 @@ # ########################################################## from tclCommands.TclCommand import TclCommand -from ObjectCollection import * + +import collections from camlib import get_bounds +import logging import gettext import FlatCAMTranslation as fcTranslate import builtins @@ -18,6 +20,8 @@ fcTranslate.apply_language('strings') if '_' not in builtins.__dict__: _ = gettext.gettext +log = logging.getLogger('base') + class TclCommandSetOrigin(TclCommand): """ diff --git a/tclCommands/TclCommandSetSys.py b/tclCommands/TclCommandSetSys.py index 137bdf31..9d477e27 100644 --- a/tclCommands/TclCommandSetSys.py +++ b/tclCommands/TclCommandSetSys.py @@ -1,6 +1,7 @@ -from ObjectCollection import * from tclCommands.TclCommand import TclCommand +import collections + class TclCommandSetSys(TclCommand): """ diff --git a/tclCommands/TclCommandSkew.py b/tclCommands/TclCommandSkew.py index ac44e9c6..60902b10 100644 --- a/tclCommands/TclCommandSkew.py +++ b/tclCommands/TclCommandSkew.py @@ -1,6 +1,7 @@ -from ObjectCollection import * from tclCommands.TclCommand import TclCommand +import collections + class TclCommandSkew(TclCommand): """ diff --git a/tclCommands/TclCommandSubtractPoly.py b/tclCommands/TclCommandSubtractPoly.py index 54cbf8f4..9661e0b1 100644 --- a/tclCommands/TclCommandSubtractPoly.py +++ b/tclCommands/TclCommandSubtractPoly.py @@ -1,6 +1,7 @@ -from ObjectCollection import * from tclCommands.TclCommand import TclCommandSignaled +import collections + class TclCommandSubtractPoly(TclCommandSignaled): """ @@ -50,11 +51,13 @@ class TclCommandSubtractPoly(TclCommandSignaled): if len(unnamed_args) % 2 != 0: return "Incomplete coordinate." - points = [[float(unnamed_args[2 * i]), float(unnamed_args[2 * i + 1])] for i in range(len(unnamed_args) / 2)] + points = [ + [float(unnamed_args[2 * i]), float(unnamed_args[2 * i + 1])] for i in range(int(len(unnamed_args) / 2)) + ] try: obj = self.app.collection.get_by_name(str(obj_name)) - except: + except Exception as e: return "Could not retrieve object: %s" % obj_name if obj is None: return "Object not found: %s" % obj_name diff --git a/tclCommands/TclCommandSubtractRectangle.py b/tclCommands/TclCommandSubtractRectangle.py index 82aee657..f65b9f71 100644 --- a/tclCommands/TclCommandSubtractRectangle.py +++ b/tclCommands/TclCommandSubtractRectangle.py @@ -1,6 +1,15 @@ -from ObjectCollection import * from tclCommands.TclCommand import TclCommandSignaled +import collections + +import gettext +import FlatCAMTranslation as fcTranslate +import builtins + +fcTranslate.apply_language('strings') +if '_' not in builtins.__dict__: + _ = gettext.gettext + class TclCommandSubtractRectangle(TclCommandSignaled): """ @@ -61,7 +70,7 @@ class TclCommandSubtractRectangle(TclCommandSignaled): try: obj = self.app.collection.get_by_name(str(obj_name)) - except: + except Exception as e: return "Could not retrieve object: %s" % obj_name if obj is None: return "Object not found: %s" % obj_name diff --git a/tclCommands/TclCommandVersion.py b/tclCommands/TclCommandVersion.py index 693743ad..86dcc24a 100644 --- a/tclCommands/TclCommandVersion.py +++ b/tclCommands/TclCommandVersion.py @@ -1,6 +1,7 @@ -from ObjectCollection import * from tclCommands.TclCommand import TclCommand +import collections + class TclCommandVersion(TclCommand): """ @@ -44,4 +45,3 @@ class TclCommandVersion(TclCommand): """ self.app.version_check() - diff --git a/tclCommands/TclCommandWriteGCode.py b/tclCommands/TclCommandWriteGCode.py index d849f4d4..428d367c 100644 --- a/tclCommands/TclCommandWriteGCode.py +++ b/tclCommands/TclCommandWriteGCode.py @@ -1,6 +1,7 @@ -from ObjectCollection import * from tclCommands.TclCommand import TclCommandSignaled +import collections + class TclCommandWriteGCode(TclCommandSignaled): """ @@ -89,7 +90,7 @@ class TclCommandWriteGCode(TclCommandSignaled): try: obj = self.app.collection.get_by_name(str(obj_name)) - except: + except Exception as e: if muted == 0: return "Could not retrieve object: %s" % obj_name else: