- multiple fixes in the Tcl commands (especially regarding the interchange between True/false and 1/0 values)

- updated the help for all Tcl Commands
- in Tcl Shell, the 'help' command will add also a brief description for each command in the list
This commit is contained in:
Marius Stanciu
2020-04-13 19:15:20 +03:00
committed by Marius
parent 5dcddb168e
commit 8a299e8fc8
66 changed files with 350 additions and 172 deletions

View File

@@ -21,6 +21,8 @@ class TclCommandCutout(TclCommand):
# names for backward compatibility (add_poly, add_polygon)
aliases = ['cutout']
description = '%s %s' % ("--", "Creates board cutout from an object (Gerber or Geometry) with a rectangular shape.")
# Dictionary of types from Tcl command, needs to be ordered
arg_names = collections.OrderedDict([
('name', str),
@@ -32,7 +34,8 @@ class TclCommandCutout(TclCommand):
('dia', float),
('margin', float),
('gapsize', float),
('gaps', str)
('gaps', str),
('outname', str)
])
# array of mandatory options for current Tcl command: required = {'name','outname'}
@@ -40,15 +43,16 @@ class TclCommandCutout(TclCommand):
# structured help for current command, args needs to be ordered
help = {
'main': 'Creates board cutout from an object (Gerber or Geometry) with a rectangular shape',
'main': 'Creates board cutout from an object (Gerber or Geometry) with a rectangular shape.',
'args': collections.OrderedDict([
('name', 'Name of the object.'),
('dia', 'Tool diameter. Default = 0.1'),
('margin', 'Margin over bounds. Default = 0.001'),
('gapsize', 'Size of gap. Default = 0.1'),
('gaps', "Type of gaps. Can be: 'tb' = top-bottom, 'lr' = left-right and '4' = one each side. Default = 4"),
('dia', 'Tool diameter.'),
('margin', 'Margin over bounds.'),
('gapsize', 'Size of gap.'),
('gaps', "Type of gaps. Can be: 'tb' = top-bottom, 'lr' = left-right and '4' = one each side."),
('outname', 'Name of the object to create.')
]),
'examples': ['cutout new_geo -dia 1.2 -margin 0.1 -gapsize 1 -gaps "tb" ']
'examples': ['cutout new_geo -dia 1.2 -margin 0.1 -gapsize 1 -gaps "tb" -outname cut_geo']
}
def execute(self, args, unnamed_args):
@@ -69,22 +73,27 @@ class TclCommandCutout(TclCommand):
if 'margin' in args:
margin_par = float(args['margin'])
else:
margin_par = 0.001
margin_par = float(self.app.defaults["tools_cutoutmargin"])
if 'dia' in args:
dia_par = float(args['dia'])
else:
dia_par = 0.1
dia_par = float(self.app.defaults["tools_cutouttooldia"])
if 'gaps' in args:
gaps_par = args['gaps']
else:
gaps_par = "4"
gaps_par = str(self.app.defaults["tools_gaps_ff"])
if 'gapsize' in args:
gapsize_par = float(args['gapsize'])
else:
gapsize_par = 0.1
gapsize_par = float(self.app.defaults["tools_cutoutgapsize"])
if 'outname' in args:
outname = args['outname']
else:
outname = name + "_cutout"
try:
obj = self.app.collection.get_by_name(str(name))
@@ -128,7 +137,7 @@ class TclCommandCutout(TclCommand):
geo_obj.solid_geometry = cascaded_union([LineString(segment) for segment in cuts])
try:
self.app.new_object("geometry", name + "_cutout", geo_init_me, plot=False)
self.app.new_object("geometry", outname, geo_init_me, plot=False)
self.app.inform.emit("[success] Rectangular-form Cutout operation finished.")
except Exception as e:
return "Operation failed: %s" % str(e)