Procházet zdrojové kódy

- fixed imports in all TclCommands

Marius Stanciu před 6 roky
rodič
revize
d0e5b6c83a
57 změnil soubory, kde provedl 206 přidání a 90 odebrání
  1. 3 2
      README.md
  2. 2 2
      tclCommands/TclCommandAddCircle.py
  3. 1 1
      tclCommands/TclCommandAddPolygon.py
  4. 2 1
      tclCommands/TclCommandAddPolyline.py
  5. 2 2
      tclCommands/TclCommandAddRectangle.py
  6. 5 1
      tclCommands/TclCommandAlignDrill.py
  7. 2 1
      tclCommands/TclCommandAlignDrillGrid.py
  8. 5 1
      tclCommands/TclCommandBbox.py
  9. 3 3
      tclCommands/TclCommandBounds.py
  10. 1 1
      tclCommands/TclCommandClearShell.py
  11. 4 1
      tclCommands/TclCommandCncjob.py
  12. 5 1
      tclCommands/TclCommandCopperClear.py
  13. 6 1
      tclCommands/TclCommandCutout.py
  14. 2 1
      tclCommands/TclCommandDelete.py
  15. 5 2
      tclCommands/TclCommandDrillcncjob.py
  16. 3 1
      tclCommands/TclCommandExportGcode.py
  17. 2 3
      tclCommands/TclCommandExportSVG.py
  18. 3 1
      tclCommands/TclCommandExteriors.py
  19. 3 1
      tclCommands/TclCommandFollow.py
  20. 6 1
      tclCommands/TclCommandGeoCutout.py
  21. 3 2
      tclCommands/TclCommandGeoUnion.py
  22. 2 1
      tclCommands/TclCommandGetNames.py
  23. 2 2
      tclCommands/TclCommandGetSys.py
  24. 3 2
      tclCommands/TclCommandImportSvg.py
  25. 3 1
      tclCommands/TclCommandInteriors.py
  26. 6 5
      tclCommands/TclCommandIsolate.py
  27. 3 1
      tclCommands/TclCommandJoinExcellon.py
  28. 3 1
      tclCommands/TclCommandJoinGeometry.py
  29. 4 2
      tclCommands/TclCommandMillDrills.py
  30. 4 1
      tclCommands/TclCommandMillSlots.py
  31. 5 3
      tclCommands/TclCommandMirror.py
  32. 2 1
      tclCommands/TclCommandNew.py
  33. 2 1
      tclCommands/TclCommandNewExcellon.py
  34. 2 1
      tclCommands/TclCommandNewGeometry.py
  35. 3 2
      tclCommands/TclCommandNewGerber.py
  36. 6 1
      tclCommands/TclCommandNregions.py
  37. 2 1
      tclCommands/TclCommandOffset.py
  38. 2 1
      tclCommands/TclCommandOpenExcellon.py
  39. 2 1
      tclCommands/TclCommandOpenGCode.py
  40. 3 1
      tclCommands/TclCommandOpenGerber.py
  41. 2 1
      tclCommands/TclCommandOpenProject.py
  42. 2 1
      tclCommands/TclCommandOptions.py
  43. 5 1
      tclCommands/TclCommandPaint.py
  44. 16 9
      tclCommands/TclCommandPanelize.py
  45. 2 1
      tclCommands/TclCommandPlotAll.py
  46. 2 1
      tclCommands/TclCommandPlotObjects.py
  47. 2 2
      tclCommands/TclCommandQuit.py
  48. 2 1
      tclCommands/TclCommandSaveProject.py
  49. 13 1
      tclCommands/TclCommandScale.py
  50. 2 1
      tclCommands/TclCommandSetActive.py
  51. 5 1
      tclCommands/TclCommandSetOrigin.py
  52. 2 1
      tclCommands/TclCommandSetSys.py
  53. 2 1
      tclCommands/TclCommandSkew.py
  54. 6 3
      tclCommands/TclCommandSubtractPoly.py
  55. 11 2
      tclCommands/TclCommandSubtractRectangle.py
  56. 2 2
      tclCommands/TclCommandVersion.py
  57. 3 2
      tclCommands/TclCommandWriteGCode.py

+ 3 - 2
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
 

+ 2 - 2
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

+ 1 - 1
tclCommands/TclCommandAddPolygon.py

@@ -1,4 +1,4 @@
-from ObjectCollection import *
+from camlib import Geometry
 from tclCommands.TclCommand import *
 
 

+ 2 - 1
tclCommands/TclCommandAddPolyline.py

@@ -1,4 +1,5 @@
-from ObjectCollection import *
+from camlib import Geometry
+import collections
 from tclCommands.TclCommand import TclCommandSignaled
 
 

+ 2 - 2
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

+ 5 - 1
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):

+ 2 - 1
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):
     """

+ 5 - 1
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

+ 3 - 3
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):
     """

+ 1 - 1
tclCommands/TclCommandClearShell.py

@@ -6,7 +6,7 @@
 # ##########################################################
 
 from tclCommands.TclCommand import TclCommand
-from ObjectCollection import *
+import collections
 
 
 class TclCommandClearShell(TclCommand):

+ 4 - 1
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):

+ 5 - 1
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):
     """

+ 6 - 1
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):
     """

+ 2 - 1
tclCommands/TclCommandDelete.py

@@ -1,6 +1,7 @@
-from ObjectCollection import *
 from tclCommands.TclCommand import TclCommand
 
+import collections
+
 
 class TclCommandDelete(TclCommand):
     """

+ 5 - 2
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()

+ 3 - 1
tclCommands/TclCommandExportGcode.py

@@ -1,5 +1,7 @@
-from ObjectCollection import *
 from tclCommands.TclCommand import TclCommandSignaled
+from camlib import CNCjob
+
+import collections
 
 
 class TclCommandExportGcode(TclCommandSignaled):

+ 2 - 3
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)

+ 3 - 1
tclCommands/TclCommandExteriors.py

@@ -1,5 +1,7 @@
-from ObjectCollection import *
 from tclCommands.TclCommand import TclCommandSignaled
+from camlib import Geometry
+
+import collections
 
 
 class TclCommandExteriors(TclCommandSignaled):

+ 3 - 1
tclCommands/TclCommandFollow.py

@@ -1,5 +1,7 @@
-from ObjectCollection import *
 from tclCommands.TclCommand import TclCommandSignaled
+from FlatCAMObj import FlatCAMGerber
+
+import collections
 
 
 class TclCommandFollow(TclCommandSignaled):

+ 6 - 1
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):
     """

+ 3 - 2
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:

+ 2 - 1
tclCommands/TclCommandGetNames.py

@@ -1,6 +1,7 @@
-from ObjectCollection import *
 from tclCommands.TclCommand import TclCommand
 
+import collections
+
 
 class TclCommandGetNames(TclCommand):
     """

+ 2 - 2
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]
-

+ 3 - 2
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)
-

+ 3 - 1
tclCommands/TclCommandInteriors.py

@@ -1,5 +1,7 @@
-from ObjectCollection import *
 from tclCommands.TclCommand import TclCommandSignaled
+from camlib import Geometry
+
+import collections
 
 
 class TclCommandInteriors(TclCommandSignaled):

+ 6 - 5
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

+ 3 - 1
tclCommands/TclCommandJoinExcellon.py

@@ -1,5 +1,7 @@
-from ObjectCollection import *
 from tclCommands.TclCommand import TclCommand
+from FlatCAMObj import FlatCAMExcellon
+
+import collections
 
 
 class TclCommandJoinExcellon(TclCommand):

+ 3 - 1
tclCommands/TclCommandJoinGeometry.py

@@ -1,5 +1,7 @@
-from ObjectCollection import *
 from tclCommands.TclCommand import TclCommand
+from FlatCAMObj import FlatCAMGeometry
+
+import collections
 
 
 class TclCommandJoinGeometry(TclCommand):

+ 4 - 2
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)
 

+ 4 - 1
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):

+ 5 - 3
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:

+ 2 - 1
tclCommands/TclCommandNew.py

@@ -1,6 +1,7 @@
-from ObjectCollection import *
 from tclCommands.TclCommand import TclCommand
 
+import collections
+
 
 class TclCommandNew(TclCommand):
     """

+ 2 - 1
tclCommands/TclCommandNewExcellon.py

@@ -5,9 +5,10 @@
 # MIT Licence                                              #
 # ##########################################################
 
-from ObjectCollection import *
 from tclCommands.TclCommand import TclCommandSignaled
 
+import collections
+
 
 class TclCommandNewExcellon(TclCommandSignaled):
     """

+ 2 - 1
tclCommands/TclCommandNewGeometry.py

@@ -1,6 +1,7 @@
-from ObjectCollection import *
 from tclCommands.TclCommand import TclCommandSignaled
 
+import collections
+
 
 class TclCommandNewGeometry(TclCommandSignaled):
     """

+ 3 - 2
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

+ 6 - 1
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

+ 2 - 1
tclCommands/TclCommandOffset.py

@@ -1,6 +1,7 @@
-from ObjectCollection import *
 from tclCommands.TclCommand import TclCommand
 
+import collections
+
 
 class TclCommandOffset(TclCommand):
     """

+ 2 - 1
tclCommands/TclCommandOpenExcellon.py

@@ -1,6 +1,7 @@
-from ObjectCollection import *
 from tclCommands.TclCommand import TclCommandSignaled
 
+import collections
+
 
 class TclCommandOpenExcellon(TclCommandSignaled):
     """

+ 2 - 1
tclCommands/TclCommandOpenGCode.py

@@ -1,6 +1,7 @@
-from ObjectCollection import *
 from tclCommands.TclCommand import TclCommandSignaled
 
+import collections
+
 
 class TclCommandOpenGCode(TclCommandSignaled):
     """

+ 3 - 1
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):

+ 2 - 1
tclCommands/TclCommandOpenProject.py

@@ -1,6 +1,7 @@
-from ObjectCollection import *
 from tclCommands.TclCommand import TclCommandSignaled
 
+import collections
+
 
 class TclCommandOpenProject(TclCommandSignaled):
     """

+ 2 - 1
tclCommands/TclCommandOptions.py

@@ -1,6 +1,7 @@
-from ObjectCollection import *
 from tclCommands.TclCommand import TclCommandSignaled
 
+import collections
+
 
 class TclCommandOptions(TclCommandSignaled):
     """

+ 5 - 1
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):
     """

+ 16 - 9
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()
 

+ 2 - 1
tclCommands/TclCommandPlotAll.py

@@ -1,6 +1,7 @@
-from ObjectCollection import *
 from tclCommands.TclCommand import TclCommand
 
+import collections
+
 
 class TclCommandPlotAll(TclCommand):
     """

+ 2 - 1
tclCommands/TclCommandPlotObjects.py

@@ -5,9 +5,10 @@
 # MIT Licence                                              #
 # ##########################################################
 
-from ObjectCollection import *
 from tclCommands.TclCommand import TclCommand
 
+import collections
+
 
 class TclCommandPlotObjects(TclCommand):
     """

+ 2 - 2
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()
-

+ 2 - 1
tclCommands/TclCommandSaveProject.py

@@ -1,6 +1,7 @@
-from ObjectCollection import *
 from tclCommands.TclCommand import TclCommandSignaled
 
+import collections
+
 
 class TclCommandSaveProject(TclCommandSignaled):
     """

+ 13 - 1
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):
     """

+ 2 - 1
tclCommands/TclCommandSetActive.py

@@ -1,6 +1,7 @@
-from ObjectCollection import *
 from tclCommands.TclCommand import TclCommand
 
+import collections
+
 
 class TclCommandSetActive(TclCommand):
     """

+ 5 - 1
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):
     """

+ 2 - 1
tclCommands/TclCommandSetSys.py

@@ -1,6 +1,7 @@
-from ObjectCollection import *
 from tclCommands.TclCommand import TclCommand
 
+import collections
+
 
 class TclCommandSetSys(TclCommand):
     """

+ 2 - 1
tclCommands/TclCommandSkew.py

@@ -1,6 +1,7 @@
-from ObjectCollection import *
 from tclCommands.TclCommand import TclCommand
 
+import collections
+
 
 class TclCommandSkew(TclCommand):
     """

+ 6 - 3
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

+ 11 - 2
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

+ 2 - 2
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()
-

+ 3 - 2
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: