Kaynağa Gözat

- updated Tcl commands to make use of either 0 or False for False value or 1 or True for True in case of a parameter with type Bool

Marius Stanciu 6 yıl önce
ebeveyn
işleme
e54dd14e6c

+ 1 - 0
README.md

@@ -16,6 +16,7 @@ CAD program, and create G-Code for Isolation routing.
 - fixed an small issue in Object UI
 - small fixes: selected object in Project used to ask twice for UI build; if scale factor in Object UI is 1 do nothing as there is no point in scaling with a factor of 1
 - in Geometry UI added a button that allow updating all the tools in the Tool Table with the current values in the UI form
+- updated Tcl commands to make use of either 0 or False for False value or 1 or True for True in case of a parameter with type Bool
 
 7.12.2019 
 

+ 1 - 1
tclCommands/TclCommandBbox.py

@@ -79,7 +79,7 @@ class TclCommandBbox(TclCommand):
 
         if 'rounded' not in args:
             args['rounded'] = self.app.defaults["gerber_bboxrounded"]
-        rounded = args['rounded']
+        rounded = bool(args['rounded'])
 
         del args['name']
 

+ 4 - 4
tclCommands/TclCommandCopperClear.py

@@ -126,18 +126,18 @@ class TclCommandCopperClear(TclCommand):
             method = str(self.app.defaults["tools_nccmethod"])
 
         if 'connect' in args:
-            connect = eval(str(args['connect']).capitalize())
+            connect = bool(args['connect'])
         else:
             connect = eval(str(self.app.defaults["tools_nccconnect"]))
 
         if 'contour' in args:
-            contour = eval(str(args['contour']).capitalize())
+            contour = bool(args['contour'])
         else:
             contour = eval(str(self.app.defaults["tools_ncccontour"]))
 
         offset = 0.0
         if 'has_offset' in args:
-            has_offset = args['has_offset']
+            has_offset = bool(args['has_offset'])
             if args['has_offset'] is True:
                 if 'offset' in args:
                     offset = float(args['margin'])
@@ -203,7 +203,7 @@ class TclCommandCopperClear(TclCommand):
             })
 
         if 'rest' in args:
-            rest = eval(str(args['rest']).capitalize())
+            rest = bool(args['rest'])
         else:
             rest = eval(str(self.app.defaults["tools_nccrest"]))
 

+ 3 - 3
tclCommands/TclCommandCutout.py

@@ -67,12 +67,12 @@ class TclCommandCutout(TclCommand):
             return
 
         if 'margin' in args:
-            margin_par = args['margin']
+            margin_par = float(args['margin'])
         else:
             margin_par = 0.001
 
         if 'dia' in args:
-            dia_par = args['dia']
+            dia_par = float(args['dia'])
         else:
             dia_par = 0.1
 
@@ -82,7 +82,7 @@ class TclCommandCutout(TclCommand):
             gaps_par = "4"
 
         if 'gapsize' in args:
-            gapsize_par = args['gapsize']
+            gapsize_par = float(args['gapsize'])
         else:
             gapsize_par = 0.1
 

+ 3 - 3
tclCommands/TclCommandGeoCutout.py

@@ -137,12 +137,12 @@ class TclCommandGeoCutout(TclCommandSignaled):
             return
 
         if 'margin' in args:
-            margin = args['margin']
+            margin = float(args['margin'])
         else:
             margin = 0.001
 
         if 'dia' in args:
-            dia = args['dia']
+            dia = float(args['dia'])
         else:
             dia = 0.1
 
@@ -152,7 +152,7 @@ class TclCommandGeoCutout(TclCommandSignaled):
             gaps = 4
 
         if 'gapsize' in args:
-            gapsize = args['gapsize']
+            gapsize = float(args['gapsize'])
         else:
             gapsize = 0.1
 

+ 4 - 1
tclCommands/TclCommandMillDrills.py

@@ -79,6 +79,9 @@ class TclCommandMillDrills(TclCommandSignaled):
         if 'outname' not in args:
             args['outname'] = name + "_mill_drills"
 
+        if 'use_thread' in args:
+            args['use_thread'] = bool(args['use_thread'])
+
         if not obj.drills:
             self.raise_tcl_error("The Excellon object has no drills: %s" % name)
 
@@ -96,7 +99,7 @@ class TclCommandMillDrills(TclCommandSignaled):
                         req_dia_form = float('%.*f' % (obj.decimals, float(req_dia)))
 
                         if 'diatol' in args:
-                            tolerance = args['diatol'] / 100
+                            tolerance = float(args['diatol']) / 100
 
                             tolerance = 0.0 if tolerance < 0.0 else tolerance
                             tolerance = 1.0 if tolerance > 1.0 else tolerance

+ 3 - 0
tclCommands/TclCommandMillSlots.py

@@ -79,6 +79,9 @@ class TclCommandMillSlots(TclCommandSignaled):
         if 'outname' not in args:
             args['outname'] = name + "_mill_slots"
 
+        if 'use_thread' in args:
+            args['use_thread'] = bool(args['use_thread'])
+
         if not obj.slots:
             self.raise_tcl_error("The Excellon object has no slots: %s" % name)
 

+ 2 - 2
tclCommands/TclCommandNregions.py

@@ -74,11 +74,11 @@ class TclCommandNregions(TclCommand):
 
         if 'margin' not in args:
             args['margin'] = float(self.app.defaults["gerber_noncoppermargin"])
-        margin = args['margin']
+        margin = float(args['margin'])
 
         if 'rounded' not in args:
             args['rounded'] = self.app.defaults["gerber_noncopperrounded"]
-        rounded = args['rounded']
+        rounded = bool(args['rounded'])
 
         del args['name']
 

+ 1 - 1
tclCommands/TclCommandOffset.py

@@ -49,6 +49,6 @@ class TclCommandOffset(TclCommand):
         """
 
         name = args['name']
-        x, y = args['x'], args['y']
+        x, y = float(args['x']), float(args['y'])
 
         self.app.collection.get_by_name(name).offset((x, y))

+ 5 - 5
tclCommands/TclCommandPaint.py

@@ -123,12 +123,12 @@ class TclCommandPaint(TclCommand):
             method = str(self.app.defaults["tools_paintmethod"])
 
         if 'connect' in args:
-            connect = eval(str(args['connect']).capitalize())
+            connect = bool(args['connect'])
         else:
             connect = eval(str(self.app.defaults["tools_pathconnect"]))
 
         if 'contour' in args:
-            contour = eval(str(args['contour']).capitalize())
+            contour = bool(args['contour'])
         else:
             contour = eval(str(self.app.defaults["tools_paintcontour"]))
 
@@ -195,7 +195,7 @@ class TclCommandPaint(TclCommand):
             return "Object not found: %s" % name
 
         # Paint all polygons in the painted object
-        if 'all' in args and args['all'] is True:
+        if 'all' in args and bool(args['all']) is True:
             self.app.paint_tool.paint_poly_all(obj=obj,
                                                tooldia=tooldia,
                                                overlap=overlap,
@@ -211,7 +211,7 @@ class TclCommandPaint(TclCommand):
             return
 
         # Paint single polygon in the painted object
-        elif 'single' in args and args['single'] is True:
+        elif 'single' in args and bool(args['single']) is True:
             if 'x' not in args or 'y' not in args:
                 self.raise_tcl_error('%s' % _("Expected -x <value> and -y <value>."))
             else:
@@ -234,7 +234,7 @@ class TclCommandPaint(TclCommand):
             return
 
         # Paint all polygons found within the box object from the the painted object
-        elif 'ref' in args and args['ref'] is True:
+        elif 'ref' in args and bool(args['ref']) is True:
             if 'box' not in args:
                 self.raise_tcl_error('%s' % _("Expected -box <value>."))
             else:

+ 10 - 10
tclCommands/TclCommandPanelize.py

@@ -34,7 +34,7 @@ class TclCommandPanelize(TclCommand):
         ('spacing_rows', float),
         ('box', str),
         ('outname', str),
-        ('threaded', int)
+        ('run_threaded', bool)
     ])
 
     # array of mandatory options for current Tcl command: required = {'name','outname'}
@@ -52,7 +52,7 @@ class TclCommandPanelize(TclCommand):
             ('columns', 'Number of columns.'),
             ('rows', 'Number of rows;'),
             ('outname', 'Name of the new geometry object.'),
-            ('threaded', '0 = non-threaded || 1 = threaded')
+            ('run_threaded', 'False = non-threaded || True = threaded')
         ]),
         'examples': []
     }
@@ -93,23 +93,23 @@ class TclCommandPanelize(TclCommand):
         else:
             outname = name + '_panelized'
 
-        if 'threaded' in args:
-            threaded = args['threaded']
+        if 'run_threaded' in args:
+            threaded = bool(args['run_threaded'])
         else:
-            threaded = 0
+            threaded = False
 
         if 'spacing_columns' in args:
-            spacing_columns = args['spacing_columns']
+            spacing_columns = int(args['spacing_columns'])
         else:
             spacing_columns = 5
 
         if 'spacing_rows' in args:
-            spacing_rows = args['spacing_rows']
+            spacing_rows = int(args['spacing_rows'])
         else:
             spacing_rows = 5
 
-        rows = args['rows']
-        columns = args['columns']
+        rows = int(args['rows'])
+        columns = int(args['columns'])
 
         xmin, ymin, xmax, ymax = box.bounds()
         lenghtx = xmax - xmin + spacing_columns
@@ -277,7 +277,7 @@ class TclCommandPanelize(TclCommand):
                     self.app.progress.emit(50)
                     self.app.new_object("geometry", outname, job_init_geometry, plot=False, autoselected=True)
 
-        if threaded == 1:
+        if threaded is True:
             proc = self.app.proc_container.new("Generating panel ... Please wait.")
 
             def job_thread(app_obj):

+ 3 - 3
tclCommands/TclCommandSetOrigin.py

@@ -52,8 +52,8 @@ class TclCommandSetOrigin(TclCommand):
         'main': "Will set the origin at the specified x,y location.",
         'args': collections.OrderedDict([
             ('loc', 'Location to offset all the selected objects. No spaces between x and y pair. Use like this: 2,3'),
-            ('auto', 'If set to 1 it will set the origin to the minimum x, y of the object selection bounding box.'
-                     '-auto=1 is not correct but -auto 1 or -auto True is correct.')
+            ('auto', 'If set to True it will set the origin to the minimum x, y of the object selection bounding box.'
+                     '-auto=True is not correct but -auto 1 or -auto True is correct.')
         ]),
         'examples': ['set_origin 3,2', 'set_origin -auto 1']
     }
@@ -68,7 +68,7 @@ class TclCommandSetOrigin(TclCommand):
 
         loc = list()
         if 'auto' in args:
-            if args['auto'] == 1:
+            if bool(args['auto']) is True:
                 objs = self.app.collection.get_list()
                 minx, miny, __, ___ = get_bounds(objs)