Sfoglia il codice sorgente

- added the outname parameter (and established an default name when outname not used) for the AlignDrillGrid and AlignDrill TclCommands

Marius Stanciu 6 anni fa
parent
commit
4c1163eedd
3 ha cambiato i file con 25 aggiunte e 12 eliminazioni
  1. 1 0
      README.md
  2. 13 7
      tclCommands/TclCommandAlignDrill.py
  3. 11 5
      tclCommands/TclCommandAlignDrillGrid.py

+ 1 - 0
README.md

@@ -28,6 +28,7 @@ CAD program, and create G-Code for Isolation routing.
 - made sure that all TclCommands are not threaded
 - added new TclCommands: NewExcellon, NewGerber
 - fixed the TclCommand open_project
+- added the outname parameter (and established an default name when outname not used) for the AlignDrillGrid and AlignDrill TclCommands
 
 14.09.2019
 

+ 13 - 7
tclCommands/TclCommandAlignDrill.py

@@ -29,6 +29,7 @@ class TclCommandAlignDrill(TclCommandSignaled):
         ('axisoffset', float),
         ('dia', float),
         ('dist', float),
+        ('outname', str),
     ])
 
     # array of mandatory options for current Tcl command: required = {'name','outname'}
@@ -47,9 +48,11 @@ class TclCommandAlignDrill(TclCommandSignaled):
             ('minoffset', 'min and max distance between align hole and pcb.'),
             ('axisoffset', 'Offset on second axis before aligment holes'),
             ('axis', 'Mirror axis parallel to the X or Y axis.'),
-            ('dist', 'Distance of the mirror axis to the X or Y axis.')
+            ('dist', 'Distance of the mirror axis to the X or Y axis.'),
+            ('outname', 'Name of the resulting Excellon object.'),
         ]),
-        'examples': []
+        'examples': ['aligndrill my_object -axis X -box my_object -dia 3.125 -grid 1 '
+                     '-gridoffset 0 -minoffset 2 -axisoffset 2']
     }
 
     def execute(self, args, unnamed_args):
@@ -64,6 +67,11 @@ class TclCommandAlignDrill(TclCommandSignaled):
 
         name = args['name']
 
+        if 'outname' in args:
+            outname = args['outname']
+        else:
+            outname = name + "_aligndrill"
+
         # Get source object.
         try:
             obj = self.app.collection.get_by_name(str(name))
@@ -176,9 +184,7 @@ class TclCommandAlignDrill(TclCommandSignaled):
                 px = 0.5 * (xmin + xmax)
                 py = 0.5 * (ymin + ymax)
 
-                obj.app.new_object("excellon",
-                                   name + "_aligndrill",
-                                   alligndrill_init_me, plot=False)
+                obj.app.new_object("excellon", outname, alligndrill_init_me, plot=False)
 
             except Exception as e:
                 return "Operation failed: %s" % str(e)
@@ -194,8 +200,8 @@ class TclCommandAlignDrill(TclCommandSignaled):
             try:
                 px = dist
                 py = dist
-                obj.app.new_object("excellon", name + "_alligndrill", alligndrill_init_me, plot=False)
+                obj.app.new_object("excellon", outname, alligndrill_init_me, plot=False)
             except Exception as e:
                 return "Operation failed: %s" % str(e)
 
-        return 'Ok. Align Drills Excelon object created'
+        return 'Ok. Align Drills Excellon object created'

+ 11 - 5
tclCommands/TclCommandAlignDrillGrid.py

@@ -17,7 +17,7 @@ class TclCommandAlignDrillGrid(TclCommandSignaled):
     # Dictionary of types from Tcl command, needs to be ordered.
     # For positional arguments
     arg_names = collections.OrderedDict([
-        ('outname', str)
+
     ])
 
     # Dictionary of types from Tcl command, needs to be ordered.
@@ -29,11 +29,12 @@ class TclCommandAlignDrillGrid(TclCommandSignaled):
         ('gridy', float),
         ('gridoffsety', float),
         ('columns', int),
-        ('rows', int)
+        ('rows', int),
+        ('outname', str)
     ])
 
     # array of mandatory options for current Tcl command: required = {'name','outname'}
-    required = ['outname', 'gridx', 'gridy', 'columns', 'rows']
+    required = ['gridx', 'gridy', 'columns', 'rows']
 
     # structured help for current command, args needs to be ordered
     help = {
@@ -48,7 +49,7 @@ class TclCommandAlignDrillGrid(TclCommandSignaled):
             ('colums', 'Number of grid holes on X axis.'),
             ('rows', 'Number of grid holes on Y axis.'),
         ]),
-        'examples': []
+        'examples': ['aligndrillgrid -rows 2 -columns 2 -gridoffsetx 10 -gridoffsety 10 -gridx 2.54 -gridy 5.08']
     }
 
     def execute(self, args, unnamed_args):
@@ -61,6 +62,11 @@ class TclCommandAlignDrillGrid(TclCommandSignaled):
         :return: None or exception
         """
 
+        if 'outname' in args:
+            outname = args['outname']
+        else:
+            outname = "new_aligndrill_grid"
+
         if 'gridoffsetx' not in args:
             gridoffsetx = 0
         else:
@@ -102,4 +108,4 @@ class TclCommandAlignDrillGrid(TclCommandSignaled):
             init_obj.create_geometry()
 
         # Create the new object
-        self.app.new_object("excellon", args['outname'], aligndrillgrid_init_me, plot=False)
+        self.app.new_object("excellon", outname, aligndrillgrid_init_me, plot=False)