- 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

@ -11927,9 +11927,22 @@ class App(QtCore.QObject):
def shelp(p=None):
if not p:
return _("Available commands:\n") + \
'\n'.join([' ' + cmd for cmd in sorted(commands)]) + \
_("\n\nType help <command_name> for usage.\n Example: help open_gerber")
cmd_enum = _("Available commands:\n")
displayed_text = []
try:
for cmd_name in sorted(commands):
cmd_description = commands[cmd_name]['description']
cmd_line_txt = ' %s\t\t%s' % (str(cmd_name), cmd_description)
displayed_text.append(cmd_line_txt)
except Exception as err:
log.debug("App.setup_shell.shelp() when run as 'help' --> %s" % str(err))
displayed_text = [' %s' % cmd for cmd in sorted(commands)]
cmd_enum += '\n'.join(displayed_text)
cmd_enum += '\n\n%s\n%s' % (_("Type help <command_name> for usage."), _("Example: help open_gerber"))
return cmd_enum
if p not in commands:
return "Unknown command: %s" % p
@ -12079,7 +12092,8 @@ class App(QtCore.QObject):
commands = {
'help': {
'fcn': shelp,
'help': _("Shows list of commands.")
'help': _("Shows list of commands."),
'description': ''
},
}

View File

@ -7505,7 +7505,7 @@ class FlatCAMCNCjob(FlatCAMObj, CNCjob):
self.app.inform.emit('[ERROR] %s' % _("There is no preprocessor file."))
def get_gcode(self, preamble='', postamble=''):
# we need this to be able get_gcode separatelly for shell command export_gcode
# we need this to be able get_gcode separately for shell command export_gcode
return preamble + '\n' + self.gcode + "\n" + postamble
def get_svg(self):

View File

@ -12,6 +12,9 @@ CAD program, and create G-Code for Isolation routing.
13.04.2020
- added the outname parameter for the geocutout Tcl command
- 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
11.04.2020

View File

@ -58,6 +58,8 @@ class TclCommand(object):
raise TypeError('Expected FlatCAMApp, got %s.' % type(app))
self.log = self.app.log
self.error_info = None
self.error = None
def raise_tcl_error(self, text):
"""

View File

@ -13,6 +13,8 @@ class TclCommandAddCircle(TclCommand):
# List of all command aliases, to be able use old names for backward compatibility (add_poly, add_polygon)
aliases = ['add_circle']
description = '%s %s' % ("--", "Creates a circle in the given Geometry object.")
# Dictionary of types from Tcl command, needs to be ordered
arg_names = collections.OrderedDict([
('name', str),

View File

@ -10,6 +10,8 @@ class TclCommandAddPolygon(TclCommandSignaled):
# array of all command aliases, to be able use old names for backward compatibility (add_poly, add_polygon)
aliases = ['add_polygon', 'add_poly']
description = '%s %s' % ("--", "Creates a polygon in the given Geometry object.")
# dictionary of types from Tcl command, needs to be ordered
arg_names = collections.OrderedDict([
('name', str)

View File

@ -11,6 +11,8 @@ class TclCommandAddPolyline(TclCommandSignaled):
# array of all command aliases, to be able use old names for backward compatibility (add_poly, add_polygon)
aliases = ['add_polyline']
description = '%s %s' % ("--", "Creates a polyline in the given Geometry object.")
# dictionary of types from Tcl command, needs to be ordered
arg_names = collections.OrderedDict([
('name', str)

View File

@ -10,6 +10,8 @@ class TclCommandAddRectangle(TclCommandSignaled):
# array of all command aliases, to be able use old names for backward compatibility (add_poly, add_polygon)
aliases = ['add_rectangle']
description = '%s %s' % ("--", "Creates a rectangle in the given Geometry object.")
# Dictionary of types from Tcl command, needs to be ordered.
# For positional arguments
arg_names = collections.OrderedDict([
@ -31,7 +33,7 @@ class TclCommandAddRectangle(TclCommandSignaled):
# structured help for current command, args needs to be ordered
help = {
'main': "Add a rectange to the given Geometry object.",
'main': "Creates a rectangle in the given Geometry object.",
'args': collections.OrderedDict([
('name', 'Name of the Geometry object in which to add the rectangle.'),
('x0 y0', 'Bottom left corner coordinates.'),

View File

@ -15,6 +15,8 @@ class TclCommandAlignDrill(TclCommandSignaled):
# backward compatibility (add_poly, add_polygon)
aliases = ['aligndrill']
description = '%s %s' % ("--", "Create an Excellon object with drills for alignment.")
# Dictionary of types from Tcl command, needs to be ordered.
# For positional arguments
arg_names = collections.OrderedDict([

View File

@ -15,6 +15,8 @@ class TclCommandAlignDrillGrid(TclCommandSignaled):
# backward compatibility (add_poly, add_polygon)
aliases = ['aligndrillgrid']
description = '%s %s' % ("--", "Create an Excellon object with drills for alignment arranged in a grid.")
# Dictionary of types from Tcl command, needs to be ordered.
# For positional arguments
arg_names = collections.OrderedDict([
@ -41,7 +43,6 @@ class TclCommandAlignDrillGrid(TclCommandSignaled):
help = {
'main': "Create an Excellon object with drills for alignment arranged in a grid.",
'args': collections.OrderedDict([
('outname', 'Name of the object to create.'),
('dia', 'Tool diameter.'),
('gridx', 'Grid size in X axis.'),
('gridoffsetx', 'Move grid from origin.'),
@ -49,6 +50,7 @@ class TclCommandAlignDrillGrid(TclCommandSignaled):
('gridoffsety', 'Move grid from origin.'),
('colums', 'Number of grid holes on X axis.'),
('rows', 'Number of grid holes on Y axis.'),
('outname', 'Name of the object to create.')
]),
'examples': ['aligndrillgrid -rows 2 -columns 2 -gridoffsetx 10 -gridoffsety 10 -gridx 2.54 -gridy 5.08']
}

View File

@ -21,6 +21,8 @@ class TclCommandBbox(TclCommand):
# array of all command aliases, to be able use old names for backward compatibility (add_poly, add_polygon)
aliases = ['bounding_box', 'bbox']
description = '%s %s' % ("--", "Creates a rectangular Geometry object that surrounds the object.")
# dictionary of types from Tcl command, needs to be ordered
arg_names = collections.OrderedDict([
('name', str)
@ -30,7 +32,7 @@ class TclCommandBbox(TclCommand):
option_types = collections.OrderedDict([
('outname', str),
('margin', float),
('rounded', bool)
('rounded', str)
])
# array of mandatory options for current Tcl command: required = {'name','outname'}
@ -41,11 +43,11 @@ class TclCommandBbox(TclCommand):
'main': "Creates a rectangular Geometry object that surrounds the object.",
'args': collections.OrderedDict([
('name', 'Object name for which to create bounding box. String'),
('outname', 'Name of the resulting Geometry object. String.'),
('margin', "Distance of the edges of the box to the nearest polygon."
"Float number."),
('rounded', "If the bounding box is to have rounded corners their radius is equal to the margin. "
"True or False.")
"True (1) or False (0)."),
('outname', 'Name of the resulting Geometry object. String.')
]),
'examples': ['bbox name -outname name_bbox']
}
@ -78,8 +80,8 @@ class TclCommandBbox(TclCommand):
margin = args['margin']
if 'rounded' not in args:
args['rounded'] = self.app.defaults["gerber_bboxrounded"]
rounded = bool(args['rounded'])
args['rounded'] = bool(eval(self.app.defaults["gerber_bboxrounded"]))
rounded = bool(eval(args['rounded']))
del args['name']

View File

@ -23,6 +23,8 @@ class TclCommandBounds(TclCommand):
# List of all command aliases, to be able use old names for backward compatibility (add_poly, add_polygon)
aliases = ['get_bounds', 'bounds']
description = '%s %s' % ("--", "Return in the console a list of bounds values for a list of objects.")
# Dictionary of types from Tcl command, needs to be ordered
arg_names = collections.OrderedDict([
('objects', str)
@ -38,7 +40,7 @@ class TclCommandBounds(TclCommand):
# structured help for current command, args needs to be ordered
help = {
'main': "Will return a list of bounds values, each set of bound values is "
"a list itself: [xmin, ymin, xmax, ymax].",
"a list itself: [xmin, ymin, xmax, ymax] corresponding to each of the provided objects.",
'args': collections.OrderedDict([
('objects', 'A list of object names separated by comma without spaces.'),
]),

View File

@ -20,6 +20,8 @@ class TclCommandClearShell(TclCommand):
# List of all command aliases, to be able use old names for backward compatibility (add_poly, add_polygon)
aliases = ['clear']
description = '%s %s' % ("--", "Clear the text in the Tcl Shell.")
# Dictionary of types from Tcl command, needs to be ordered
arg_names = collections.OrderedDict([
@ -35,7 +37,7 @@ class TclCommandClearShell(TclCommand):
# structured help for current command, args needs to be ordered
help = {
'main': "Clear the text in the Tcl Shell browser.",
'main': "Clear the text in the Tcl Shell.",
'args': collections.OrderedDict([
]),
'examples': ['clear']

View File

@ -20,6 +20,8 @@ class TclCommandCncjob(TclCommandSignaled):
# array of all command aliases, to be able use old names for backward compatibility (add_poly, add_polygon)
aliases = ['cncjob']
description = '%s %s' % ("--", "Generates a CNC Job object from a Geometry Object.")
# dictionary of types from Tcl command, needs to be ordered
arg_names = collections.OrderedDict([
('name', str)
@ -42,7 +44,7 @@ class TclCommandCncjob(TclCommandSignaled):
('spindlespeed', int),
('dwelltime', float),
('pp', str),
('muted', int),
('muted', str),
('outname', str)
])
@ -51,7 +53,7 @@ class TclCommandCncjob(TclCommandSignaled):
# structured help for current command, args needs to be ordered
help = {
'main': "Generates a CNC Job from a Geometry Object.",
'main': "Generates a CNC Job object from a Geometry Object.",
'args': collections.OrderedDict([
('name', 'Name of the source object.'),
('dia', 'Tool diameter to show on screen.'),
@ -72,7 +74,7 @@ class TclCommandCncjob(TclCommandSignaled):
'If it is not used in command then it will not be included'),
('outname', 'Name of the resulting Geometry object.'),
('pp', 'Name of the Geometry preprocessor. No quotes, case sensitive'),
('muted', 'It will not put errors in the Shell.')
('muted', 'It will not put errors in the Shell. Can be True (1) or False (0)')
]),
'examples': ['cncjob geo_name -dia 0.5 -z_cut -1.7 -z_move 2 -feedrate 120 -pp default']
}
@ -90,14 +92,14 @@ class TclCommandCncjob(TclCommandSignaled):
name = ''
if 'muted' in args:
muted = args['muted']
muted = bool(eval(args['muted']))
else:
muted = 0
muted = False
try:
name = args['name']
except KeyError:
if muted == 0:
if muted is False:
self.raise_tcl_error("Object name is missing")
else:
return "fail"
@ -108,13 +110,13 @@ class TclCommandCncjob(TclCommandSignaled):
obj = self.app.collection.get_by_name(str(name), isCaseSensitive=False)
if obj is None:
if muted == 0:
if muted is False:
self.raise_tcl_error("Object not found: %s" % str(name))
else:
return "fail"
if not isinstance(obj, FlatCAMGeometry):
if muted == 0:
if muted is False:
self.raise_tcl_error('Expected FlatCAMGeometry, got %s %s.' % (str(name), type(obj)))
else:
return
@ -187,7 +189,7 @@ class TclCommandCncjob(TclCommandSignaled):
else:
if args[arg] is None:
print(arg, args[arg])
if muted == 0:
if muted is False:
self.raise_tcl_error('One of the command parameters that have to be not None, is None.\n'
'The parameter that is None is in the default values found in the list \n'
'generated by the TclCommand "list_sys geom". or in the arguments.')

View File

@ -22,6 +22,8 @@ class TclCommandCopperClear(TclCommand):
# Array of all command aliases, to be able use old names for backward compatibility (add_poly, add_polygon)
aliases = ['ncc_clear', 'ncc']
description = '%s %s' % ("--", "Clear excess copper.")
# dictionary of types from Tcl command, needs to be ordered
arg_names = collections.OrderedDict([
('name', str),
@ -34,13 +36,13 @@ class TclCommandCopperClear(TclCommand):
('order', str),
('margin', float),
('method', str),
('connect', bool),
('contour', bool),
('has_offset', bool),
('connect', str),
('contour', str),
('has_offset', str),
('offset', float),
('rest', bool),
('rest', str),
('all', int),
('ref', int),
('ref', str),
('box', str),
('outname', str),
])
@ -64,15 +66,15 @@ class TclCommandCopperClear(TclCommand):
'"fwd" -> tools are ordered from smallest to biggest.'
'"rev" -> tools are ordered from biggest to smallest.'),
('method', 'Algorithm for copper clearing. Can be: "standard", "seed" or "lines".'),
('connect', 'Draw lines to minimize tool lifts. True or False'),
('contour', 'Cut around the perimeter of the painting. True or False'),
('rest', 'Use rest-machining. True or False'),
('has_offset', 'The offset will used only if this is set True or present in args. True or False.'),
('connect', 'Draw lines to minimize tool lifts. True (1) or False (0)'),
('contour', 'Cut around the perimeter of the painting. True (1) or False (0)'),
('rest', 'Use rest-machining. True (1) or False (0)'),
('has_offset', 'The offset will used only if this is set True or present in args. True (1) or False (0).'),
('offset', 'The copper clearing will finish to a distance from copper features. Float number.'),
('all', 'Will copper clear the whole object. 1 or True = enabled, anything else = disabled'),
('ref', 'Will clear of extra copper all polygons within a specified object with the name in "box" '
'parameter. 1 or True = enabled, anything else = disabled'),
('box', 'Name of the object to be used as reference. Required when selecting "ref" = 1. String.'),
'parameter. 1 or True = enabled, 0 or False = disabled'),
('box', 'Name of the object to be used as reference. Required when selecting "ref" = 1 or True. String.'),
('outname', 'Name of the resulting Geometry object. String.'),
]),
'examples': ["ncc obj_name -tooldia 0.3,1 -overlap 10 -margin 1.0 -method 'lines' -all True"]
@ -127,18 +129,18 @@ class TclCommandCopperClear(TclCommand):
method = str(self.app.defaults["tools_nccmethod"])
if 'connect' in args:
connect = bool(args['connect'])
connect = bool(eval(args['connect']))
else:
connect = eval(str(self.app.defaults["tools_nccconnect"]))
connect = bool(eval(str(self.app.defaults["tools_nccconnect"])))
if 'contour' in args:
contour = bool(args['contour'])
contour = bool(eval(args['contour']))
else:
contour = eval(str(self.app.defaults["tools_ncccontour"]))
contour = bool(eval(str(self.app.defaults["tools_ncccontour"])))
offset = 0.0
if 'has_offset' in args:
has_offset = bool(args['has_offset'])
has_offset = bool(eval(args['has_offset']))
if args['has_offset'] is True:
if 'offset' in args:
offset = float(args['margin'])
@ -206,9 +208,9 @@ class TclCommandCopperClear(TclCommand):
})
if 'rest' in args:
rest = bool(args['rest'])
rest = bool(eval(args['rest']))
else:
rest = eval(str(self.app.defaults["tools_nccrest"]))
rest = bool(eval(str(self.app.defaults["tools_nccrest"])))
if 'outname' in args:
outname = args['outname']
@ -239,7 +241,7 @@ class TclCommandCopperClear(TclCommand):
return
# Non-Copper clear all polygons found within the box object from the the non_copper cleared object
elif 'ref' in args and bool(args['ref']):
elif 'ref' in args and bool(eval(args['ref'])):
if 'box' not in args:
self.raise_tcl_error('%s' % _("Expected -box <value>."))
else:

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)

View File

@ -14,6 +14,8 @@ class TclCommandDelete(TclCommand):
# List of all command aliases, to be able use old names for backward compatibility (add_poly, add_polygon)
aliases = ['delete', 'del']
description = '%s %s' % ("--", "Deletes the given object. If no name is given will delete all objects.")
# Dictionary of types from Tcl command, needs to be ordered
arg_names = collections.OrderedDict([
('name', str),

View File

@ -13,6 +13,8 @@ class TclCommandDrillcncjob(TclCommandSignaled):
# array of all command aliases, to be able use old names for backward compatibility (add_poly, add_polygon)
aliases = ['drillcncjob']
description = '%s %s' % ("--", "Generates a Drill CNC Job object from a Excellon Object.")
# dictionary of types from Tcl command, needs to be ordered
arg_names = collections.OrderedDict([
('name', str)
@ -31,10 +33,10 @@ class TclCommandDrillcncjob(TclCommandSignaled):
('endz', float),
('dwelltime', float),
('pp', str),
('outname', str),
('opt_type', str),
('diatol', float),
('muted', int)
('muted', str),
('outname', str)
])
# array of mandatory options for current Tcl command: required = {'name','outname'}
@ -60,7 +62,6 @@ class TclCommandDrillcncjob(TclCommandSignaled):
('dwelltime', 'Time to pause to allow the spindle to reach the full speed.\n'
'If it is not used in command then it will not be included'),
('pp', 'This is the Excellon preprocessor name: case_sensitive, no_quotes'),
('outname', 'Name of the resulting Geometry object.'),
('opt_type', 'Name of move optimization type. B by default for Basic OR-Tools, M for Metaheuristic OR-Tools'
'T from Travelling Salesman Algorithm. B and M works only for 64bit version of FlatCAM and '
'T works only for 32bit version of FlatCAM'),
@ -69,7 +70,8 @@ class TclCommandDrillcncjob(TclCommandSignaled):
'diameter with value 1.0, in the Excellon we have a tool with dia = 1.05 and we set a tolerance '
'diatol = 5.0 then the drills with the dia = (0.95 ... 1.05) '
'in Excellon will be processed. Float number.'),
('muted', 'It will not put errors in the Shell or status bar.')
('muted', 'It will not put errors in the Shell or status bar. Can be True (1) or False (0).'),
('outname', 'Name of the resulting Geometry object.')
]),
'examples': ['drillcncjob test.TXT -drillz -1.5 -travelz 14 -feedrate 222 -feedrate_rapid 456 -spindlespeed 777'
' -toolchangez 33 -endz 22 -pp default\n'
@ -94,7 +96,7 @@ class TclCommandDrillcncjob(TclCommandSignaled):
args['outname'] = name + "_cnc"
if 'muted' in args:
muted = bool(args['muted'])
muted = bool(eval(args['muted']))
else:
muted = False
@ -105,7 +107,7 @@ class TclCommandDrillcncjob(TclCommandSignaled):
return "fail"
if not isinstance(obj, FlatCAMExcellon):
if muted == 0:
if muted is False:
self.raise_tcl_error('Expected FlatCAMExcellon, got %s %s.' % (name, type(obj)))
else:
return "fail"
@ -143,7 +145,7 @@ class TclCommandDrillcncjob(TclCommandSignaled):
nr_diameters -= 1
if nr_diameters > 0:
if muted == 0:
if muted is False:
self.raise_tcl_error("One or more tool diameters of the drills to be drilled passed to the "
"TclCommand are not actual tool diameters in the Excellon object.")
else:
@ -164,7 +166,7 @@ class TclCommandDrillcncjob(TclCommandSignaled):
except Exception as e:
tools = 'all'
if muted == 0:
if muted is False:
self.raise_tcl_error("Bad tools: %s" % str(e))
else:
return "fail"

View File

@ -14,9 +14,11 @@ class TclCommandExportDXF(TclCommand):
# List of all command aliases, to be able use old names for backward compatibility (add_poly, add_polygon)
aliases = ['export_dxf', 'edxf']
description = '%s %s' % ("--", "Export a Geometry object as a DXF File.")
# Dictionary of types from Tcl command, needs to be ordered
arg_names = collections.OrderedDict([
('obj_name', str),
('name', str),
('filename', str)
])
@ -29,12 +31,13 @@ class TclCommandExportDXF(TclCommand):
# structured help for current command, args needs to be ordered
help = {
'main': "Export a Geometry Object as a DXF File.",
'main': "Export a Geometry object as a DXF File.",
'args': collections.OrderedDict([
('obj_name', 'Name of the object to export.'),
('filename', 'Path to the file to export.')
('name', 'Name of the Geometry object to export.'),
('filename', 'Absolute path to file to export.\n'
'WARNING: no spaces are allowed. If unsure enclose the entire path with quotes.'),
]),
'examples': ['export_dxf my_geo path/my_file.dxf']
'examples': ['export_dxf my_geo path/my_file.dxf', 'export_dxf my_geo D:/my_file.dxf']
}
def execute(self, args, unnamed_args):
@ -44,6 +47,6 @@ class TclCommandExportDXF(TclCommand):
:param unnamed_args:
:return:
"""
if 'filename' not in args:
args['filename'] = self.app.defaults["global_last_save_folder"] + '/' + args['obj_name']
self.app.export_dxf(use_thread=False,**args)
if 'filename' not in args:
args['filename'] = self.app.defaults["global_last_save_folder"] + '/' + args['name']
self.app.export_dxf(use_thread=False, **args)

View File

@ -14,9 +14,11 @@ class TclCommandExportExcellon(TclCommand):
# List of all command aliases, to be able use old names for backward compatibility (add_poly, add_polygon)
aliases = ['export_exc', 'ee', 'export_excellon']
description = '%s %s' % ("--", "Export a Excellon object as a Excellon File.")
# Dictionary of types from Tcl command, needs to be ordered
arg_names = collections.OrderedDict([
('obj_name', str),
('name', str),
('filename', str)
])
@ -25,16 +27,17 @@ class TclCommandExportExcellon(TclCommand):
])
# array of mandatory options for current Tcl command: required = ['name','outname']
required = ['obj_name']
required = ['name']
# structured help for current command, args needs to be ordered
help = {
'main': "Export a Excellon Object as a Excellon File.",
'main': "Export a Excellon object as a Excellon File.",
'args': collections.OrderedDict([
('obj_name', 'Name of the object to export.'),
('filename', 'Path to the file to export.')
('name', 'Name of the Excellon object to export.'),
('filename', 'Absolute path to file to export.\n'
'WARNING: no spaces are allowed. If unsure enclose the entire path with quotes.'),
]),
'examples': ['export_excellon my_excellon path/my_file.drl']
'examples': ['export_excellon my_excellon path/my_file.drl', 'export_excellon My_Excellon D:/drill_file.DRL']
}
def execute(self, args, unnamed_args):
@ -44,6 +47,6 @@ class TclCommandExportExcellon(TclCommand):
:param unnamed_args:
:return:
"""
if 'filename' not in args:
args['filename'] = self.app.defaults["global_last_save_folder"] + '/' + args['obj_name']
self.app.export_excellon(use_thread=False,**args)
if 'filename' not in args:
args['filename'] = self.app.defaults["global_last_save_folder"] + '/' + args['name']
self.app.export_excellon(use_thread=False, **args)

View File

@ -13,7 +13,7 @@ class TclCommandExportGcode(TclCommandSignaled):
promises and send to background if there are promises.
This export may be captured and passed as preable
This export may be captured and passed as preamble
to another "export_gcode" or "write_gcode" call to join G-Code.
example:
@ -31,11 +31,13 @@ class TclCommandExportGcode(TclCommandSignaled):
# array of all command aliases, to be able use old names for backward compatibility (add_poly, add_polygon)
aliases = ['export_gcode']
description = '%s %s' % ("--", "Return Gcode into console output.")
# dictionary of types from Tcl command, needs to be ordered
arg_names = collections.OrderedDict([
('name', str),
('preamble', str),
('postamble', str)
('postamble', str),
])
# dictionary of types from Tcl command, needs to be ordered , this is for options like -optionname value
@ -49,8 +51,8 @@ class TclCommandExportGcode(TclCommandSignaled):
'main': "Export gcode into console output.",
'args': collections.OrderedDict([
('name', 'Name of the source Geometry object. Required.'),
('preamble', 'Prepend GCODE.'),
('postamble', 'Append GCODE.')
('preamble', 'Prepend GCode to the original GCode.'),
('postamble', 'Append GCode o the original GCode.'),
]),
'examples': ['export_gcode geo_name -preamble "G01 X10 Y10" -postamble "G00 X20 Y20\nM04"']
}
@ -78,4 +80,5 @@ class TclCommandExportGcode(TclCommandSignaled):
self.raise_tcl_error('!!!Promises exists, but should not here!!!')
del args['name']
return obj.get_gcode(**args)
modified_gcode = obj.get_gcode(**args)
return

View File

@ -14,9 +14,11 @@ class TclCommandExportGerber(TclCommand):
# List of all command aliases, to be able use old names for backward compatibility (add_poly, add_polygon)
aliases = ['export_grb', 'egr', 'export_gerber']
description = '%s %s' % ("--", "Export a Gerber object as a Gerber File.")
# Dictionary of types from Tcl command, needs to be ordered
arg_names = collections.OrderedDict([
('obj_name', str),
('name', str),
('filename', str)
])
@ -31,8 +33,9 @@ class TclCommandExportGerber(TclCommand):
help = {
'main': "Export a Gerber Object as a Gerber File.",
'args': collections.OrderedDict([
('obj_name', 'Name of the object to export. Required.'),
('filename', 'Path to the file to export.')
('name', 'Name of the object to export. Required.'),
('filename', 'Absolute path to file to export.\n'
'WARNING: no spaces are allowed. If unsure enclose the entire path with quotes.'),
]),
'examples': ['export_gerber my_gerber path/my_file.gbr']
}
@ -44,6 +47,6 @@ class TclCommandExportGerber(TclCommand):
:param unnamed_args:
:return:
"""
if 'filename' not in args:
args['filename'] = self.app.defaults["global_last_save_folder"] + '/' + args['obj_name']
if 'filename' not in args:
args['filename'] = self.app.defaults["global_last_save_folder"] + '/' + args['name']
self.app.export_gerber(use_thread=False,**args)

View File

@ -1,6 +1,7 @@
from tclCommands.TclCommand import TclCommand
import collections
from copy import copy
class TclCommandExportSVG(TclCommand):
@ -14,6 +15,8 @@ class TclCommandExportSVG(TclCommand):
# List of all command aliases, to be able use old names for backward compatibility (add_poly, add_polygon)
aliases = ['export_svg']
description = '%s %s' % ("--", "Export a Geometry object as a SVG File.")
# Dictionary of types from Tcl command, needs to be ordered
arg_names = collections.OrderedDict([
('name', str),
@ -31,10 +34,11 @@ class TclCommandExportSVG(TclCommand):
# structured help for current command, args needs to be ordered
help = {
'main': "Export a Geometry Object as a SVG File.",
'main': "Export a Geometry object as a SVG File.",
'args': collections.OrderedDict([
('name', 'Name of the object export. Required.'),
('filename', 'Path to the file to export.'),
('filename', 'Absolute path to file to export.\n'
'WARNING: no spaces are allowed. If unsure enclose the entire path with quotes.'),
('scale_factor', 'Multiplication factor used for scaling line widths during export.')
]),
'examples': ['export_svg my_geometry my_file.svg']

View File

@ -12,6 +12,9 @@ class TclCommandExteriors(TclCommandSignaled):
# array of all command aliases, to be able use old names for backward compatibility (add_poly, add_polygon)
aliases = ['exteriors', 'ext']
description = '%s %s' % ("--", "Get exteriors of polygons from a Geometry object and "
"from them create a new Geometry object.")
# dictionary of types from Tcl command, needs to be ordered
arg_names = collections.OrderedDict([
('name', str)
@ -27,7 +30,7 @@ class TclCommandExteriors(TclCommandSignaled):
# structured help for current command, args needs to be ordered
help = {
'main': "Get exteriors of polygons.",
'main': "Get exteriors of polygons from a Geometry object and from them create a new Geometry object.",
'args': collections.OrderedDict([
('name', 'Name of the source Geometry object. Required.'),
('outname', 'Name of the resulting Geometry object.')

View File

@ -12,6 +12,8 @@ class TclCommandFollow(TclCommandSignaled):
# array of all command aliases, to be able use old names for backward compatibility (add_poly, add_polygon)
aliases = ['follow']
description = '%s %s' % ("--", "Creates a Geometry object following Gerber paths.")
# dictionary of types from Tcl command, needs to be ordered
arg_names = collections.OrderedDict([
('name', str)
@ -27,7 +29,7 @@ class TclCommandFollow(TclCommandSignaled):
# structured help for current command, args needs to be ordered
help = {
'main': "Creates a geometry object following gerber paths.",
'main': "Creates a Geometry object following Gerber paths.",
'args': collections.OrderedDict([
('name', 'Object name to follow. Required.'),
('outname', 'Name of the resulting Geometry object.')
@ -64,4 +66,4 @@ class TclCommandFollow(TclCommandSignaled):
return "Operation failed: %s" % str(e)
# in the end toggle the visibility of the origin object so we can see the generated Geometry
self.app.collection.get_by_name(name).ui.plot_cb.toggle()
# self.app.collection.get_by_name(name).ui.plot_cb.toggle()

View File

@ -24,6 +24,8 @@ class TclCommandGeoCutout(TclCommandSignaled):
# names for backward compatibility (add_poly, add_polygon)
aliases = ['geocutout', 'geoc']
description = '%s %s' % ("--", "Creates board cutout from an object (Gerber or Geometry) of any shape.")
# Dictionary of types from Tcl command, needs to be ordered
arg_names = collections.OrderedDict([
('name', str),
@ -44,7 +46,7 @@ class TclCommandGeoCutout(TclCommandSignaled):
# structured help for current command, args needs to be ordered
help = {
'main': 'Creates board cutout from an object (Gerber or Geometry) of any shape',
'main': 'Creates board cutout from an object (Gerber or Geometry) of any shape.',
'args': collections.OrderedDict([
('name', 'Name of the object to be cutout. Required'),
('dia', 'Tool diameter.'),
@ -141,22 +143,22 @@ class TclCommandGeoCutout(TclCommandSignaled):
if 'margin' in args:
margin = float(args['margin'])
else:
margin = 0.001
margin = float(self.app.defaults["tools_cutoutmargin"])
if 'dia' in args:
dia = float(args['dia'])
else:
dia = 0.1
dia = float(self.app.defaults["tools_cutouttooldia"])
if 'gaps' in args:
gaps = args['gaps']
else:
gaps = 4
gaps = str(self.app.defaults["tools_gaps_ff"])
if 'gapsize' in args:
gapsize = float(args['gapsize'])
else:
gapsize = 0.1
gapsize = float(self.app.defaults["tools_cutoutgapsize"])
if 'outname' in args:
outname = args['outname']

View File

@ -15,6 +15,8 @@ class TclCommandGeoUnion(TclCommand):
# List of all command aliases, to be able use old names for backward compatibility (add_poly, add_polygon)
aliases = ['geo_union']
description = '%s %s' % ("--", "Run the Union (join) geometry operation on the elements of a Geometry object.")
# Dictionary of types from Tcl command, needs to be ordered
arg_names = collections.OrderedDict([
('name', str),

View File

@ -14,6 +14,9 @@ class TclCommandGetNames(TclCommand):
# List of all command aliases, to be able use old names for backward compatibility (add_poly, add_polygon)
aliases = ['get_names']
description = '%s %s' % ("--", "Return to TCL the list of the project objects names "
"as a string with names separated by the '\\n' char.")
# Dictionary of types from Tcl command, needs to be ordered
arg_names = collections.OrderedDict([
@ -29,7 +32,8 @@ class TclCommandGetNames(TclCommand):
# structured help for current command, args needs to be ordered
help = {
'main': 'Lists the names of objects in the project. It returns a string with names separated by \n',
'main': 'Lists the names of objects in the project. '
'It returns a string with names separated by "\\n" character',
'args': collections.OrderedDict([
]),

View File

@ -21,6 +21,8 @@ class TclCommandGetSys(TclCommand):
# List of all command aliases, to be able use old names for backward compatibility (add_poly, add_polygon)
aliases = ['get_sys', 'getsys']
description = '%s %s' % ("--", "Returns to TCL the value for the entered system variable.")
# Dictionary of types from Tcl command, needs to be ordered
arg_names = collections.OrderedDict([
('name', str)
@ -36,7 +38,7 @@ class TclCommandGetSys(TclCommand):
# structured help for current command, args needs to be ordered
help = {
'main': "Returns the value of the targeted system variable.",
'main': "Returns to TCL the value for the entered system variable.",
'args': collections.OrderedDict([
('name', 'Name of the system variable. Required.'),
]),

View File

@ -12,6 +12,8 @@ class TclCommandImportSvg(TclCommandSignaled):
# array of all command aliases, to be able use old names for backward compatibility (add_poly, add_polygon)
aliases = ['import_svg']
description = '%s %s' % ("--", "Import a SVG file as a Geometry (or Gerber) Object.")
# dictionary of types from Tcl command, needs to be ordered
arg_names = collections.OrderedDict([
('filename', str)
@ -28,10 +30,11 @@ class TclCommandImportSvg(TclCommandSignaled):
# structured help for current command, args needs to be ordered
help = {
'main': "Import an SVG file as a Geometry Object..",
'main': "Import a SVG file as a Geometry (or Gerber) Object.",
'args': collections.OrderedDict([
('filename', 'Absolute path to file to open. Required.'),
('type', 'Import as gerber or geometry(default).'),
('filename', 'Absolute path to file to open. Required.\n'
'WARNING: no spaces are allowed. If unsure enclose the entire path with quotes.'),
('type', 'Import as a Gerber or Geometry (default) object. Values can be: "geometry" or "gerber"'),
('outname', 'Name of the resulting Geometry object.')
]),
'examples': ['import_svg D:\\my_beautiful_svg_file.SVG']
@ -63,12 +66,12 @@ class TclCommandImportSvg(TclCommandSignaled):
outname = filename.split('/')[-1].split('\\')[-1]
if 'type' in args:
obj_type = args['type']
obj_type = args['type'].lower()
else:
obj_type = 'geometry'
if obj_type != "geometry" and obj_type != "gerber":
self.raise_tcl_error("Option type can be 'geopmetry' or 'gerber' only, got '%s'." % obj_type)
self.raise_tcl_error("Option type can be 'geometry' or 'gerber' only, got '%s'." % obj_type)
with self.app.proc_container.new("Import SVG"):

View File

@ -12,6 +12,9 @@ class TclCommandInteriors(TclCommandSignaled):
# array of all command aliases, to be able use old names for backward compatibility (add_poly, add_polygon)
aliases = ['interiors']
description = '%s %s' % ("--", "Create a new Geometry object with the 'interiors' geo "
"elements of the source object.")
# dictionary of types from Tcl command, needs to be ordered
arg_names = collections.OrderedDict([
('name', str)
@ -27,7 +30,8 @@ class TclCommandInteriors(TclCommandSignaled):
# structured help for current command, args needs to be ordered
help = {
'main': "Return the interiors of polygons as a list of Shapely geometry elements.",
'main': "Create a new Geometry object with the 'interiors' geometric elements of "
"the specified source Geometry object.",
'args': collections.OrderedDict([
('name', 'Name of the source Geometry object. Required.'),
('outname', 'Name of the resulting Geometry object.')

View File

@ -19,6 +19,8 @@ class TclCommandIsolate(TclCommandSignaled):
# array of all command aliases, to be able use old names for backward compatibility (add_poly, add_polygon)
aliases = ['isolate']
description = '%s %s' % ("--", "Creates isolation routing Geometry for the specified Gerber object.")
# dictionary of types from Tcl command, needs to be ordered
arg_names = collections.OrderedDict([
('name', str)
@ -29,7 +31,7 @@ class TclCommandIsolate(TclCommandSignaled):
('dia', float),
('passes', int),
('overlap', float),
('combine', bool),
('combine', str),
('outname', str),
('follow', str),
('iso_type', int)
@ -41,14 +43,14 @@ class TclCommandIsolate(TclCommandSignaled):
# structured help for current command, args needs to be ordered
help = {
'main': "Creates isolation routing geometry for the given Gerber.",
'main': "Creates isolation routing Geometry for the specified Gerber object.",
'args': collections.OrderedDict([
('name', 'Name of the source object. Required.'),
('dia', 'Tool diameter.'),
('passes', 'Passes of tool width.'),
('overlap', 'Percentage of tool diameter to overlap current pass over previous pass. Float [0, 99.9999]\n'
'E.g: for a 25% from tool diameter overlap use -overlap 25'),
('combine', 'Combine all passes into one geometry. Can be True or False, 1 or 0'),
('combine', 'Combine all passes into one geometry. Can be True (1) or False (0)'),
('outname', 'Name of the resulting Geometry object.'),
('follow', 'Create a Geometry that follows the Gerber path.'),
('iso_type', 'A value of 0 will isolate exteriors, a value of 1 will isolate interiors '
@ -82,7 +84,9 @@ class TclCommandIsolate(TclCommandSignaled):
# evaluate this parameter so True, False, 0 and 1 works
if "combine" in args:
args['combine'] = eval(args['combine'])
args['combine'] = bool(eval(args['combine']))
else:
args['combine'] = bool(eval(self.app.defaults["gerber_combine_passes"]))
obj = self.app.collection.get_by_name(name)
if obj is None:

View File

@ -15,6 +15,9 @@ class TclCommandJoinExcellon(TclCommand):
# List of all command aliases, to be able use old names for backward compatibility (add_poly, add_polygon)
aliases = ['join_excellon', 'join_excellons']
description = '%s %s' % ("--", "Merge two or more Excellon objects drills and create "
"a new Excellon object with them.")
# Dictionary of types from Tcl command, needs to be ordered
arg_names = collections.OrderedDict([
('outname', str),
@ -61,7 +64,7 @@ class TclCommandJoinExcellon(TclCommand):
def initialize(obj_, app):
FlatCAMExcellon.merge(self, objs, obj_)
if objs:
if objs and len(objs) >= 2:
self.app.new_object("excellon", outname, initialize, plot=False)
else:
return "No Excellon objects to be joined."
return "No Excellon objects to be joined or less than two Excellon objects specified for merging."

View File

@ -15,6 +15,8 @@ class TclCommandJoinGeometry(TclCommand):
# List of all command aliases, to be able use old names for backward compatibility (add_poly, add_polygon)
aliases = ['join_geometries', 'join_geometry']
description = '%s %s' % ("--", "Merge two or more Geometry objects and create a new Geometry object.")
# Dictionary of types from Tcl command, needs to be ordered
arg_names = collections.OrderedDict([
('outname', str),
@ -62,7 +64,7 @@ class TclCommandJoinGeometry(TclCommand):
def initialize(obj_, app):
FlatCAMGeometry.merge(self, objs, obj_)
if objs:
if objs and len(objs) >= 2:
self.app.new_object("geometry", outname, initialize, plot=False)
else:
return "No Geometry objects to be joined."
return "No Geometry objects to be joined or less than two Geometry objects specified for merging."

View File

@ -19,6 +19,8 @@ class TclCommandListSys(TclCommand):
# List of all command aliases, to be able use old names for backward compatibility (add_poly, add_polygon)
aliases = ['list_sys', 'listsys']
description = '%s %s' % ("--", "Outputs in Tcl Shell the list with the names of system variables.")
# Dictionary of types from Tcl command, needs to be ordered
arg_names = collections.OrderedDict([
('selection', str),

View File

@ -23,6 +23,8 @@ class TclCommandMillDrills(TclCommandSignaled):
# List of all command aliases, to be able use old names for backward compatibility (add_poly, add_polygon)
aliases = ['milldrills', 'milld']
description = '%s %s' % ("--", "Create a Geometry Object for milling drill holes from Excellon.")
# Dictionary of types from Tcl command, needs to be ordered
arg_names = collections.OrderedDict([
('name', str)
@ -34,7 +36,7 @@ class TclCommandMillDrills(TclCommandSignaled):
('milled_dias', str),
('outname', str),
('tooldia', float),
('use_thread', bool),
('use_thread', str),
('diatol', float)
])
@ -43,7 +45,7 @@ class TclCommandMillDrills(TclCommandSignaled):
# structured help for current command, args needs to be ordered
help = {
'main': "Create Geometry Object for milling drill holes from Excellon.",
'main': "Create a Geometry Object for milling drill holes from Excellon.",
'args': collections.OrderedDict([
('name', 'Name of the Excellon Object. Required.'),
('milled_dias', 'Comma separated tool diameters of the drills to be milled (example: 0.6, 1.0 or 3.125).\n'
@ -51,8 +53,8 @@ class TclCommandMillDrills(TclCommandSignaled):
'WARNING: no spaces are allowed in the list of tools.\n'
'As a precaution you can enclose them with quotes.'),
('tooldia', 'Diameter of the milling tool (example: 0.1).'),
('outname', 'Name of object to be created holding the milled geometries.'),
('use_thread', 'If to use multithreading: True or False.'),
('outname', 'Name of Geometry object to be created holding the milled geometries.'),
('use_thread', 'If to use multithreading: True (1) or False (0).'),
('diatol', 'Tolerance. Percentange (0.0 ... 100.0) within which dias in milled_dias will be judged to be '
'the same as the ones in the tools from the Excellon object. E.g: if in milled_dias we have a '
'diameter with value 1.0, in the Excellon we have a tool with dia = 1.05 and we set a tolerance '
@ -84,7 +86,9 @@ class TclCommandMillDrills(TclCommandSignaled):
args['outname'] = name + "_mill_drills"
if 'use_thread' in args:
args['use_thread'] = bool(args['use_thread'])
args['use_thread'] = bool(eval(args['use_thread']))
else:
args['use_thread'] = False
if not obj.drills:
self.raise_tcl_error("The Excellon object has no drills: %s" % name)

View File

@ -23,6 +23,8 @@ class TclCommandMillSlots(TclCommandSignaled):
# List of all command aliases, to be able use old names for backward compatibility (add_poly, add_polygon)
aliases = ['millslots', 'mills']
description = '%s %s' % ("--", "Create a Geometry Object for milling slot holes from Excellon.")
# Dictionary of types from Tcl command, needs to be ordered
arg_names = collections.OrderedDict([
('name', str)
@ -34,7 +36,7 @@ class TclCommandMillSlots(TclCommandSignaled):
('milled_dias', str),
('outname', str),
('tooldia', float),
('use_thread', bool),
('use_thread', str),
('diatol', float)
])
@ -43,7 +45,7 @@ class TclCommandMillSlots(TclCommandSignaled):
# structured help for current command, args needs to be ordered
help = {
'main': "Create Geometry Object for milling slot holes from Excellon.",
'main': "Create a Geometry Object for milling slot holes from Excellon.",
'args': collections.OrderedDict([
('name', 'Name of the Excellon Object. Required.'),
('milled_dias', 'Comma separated tool diameters of the slots to be milled (example: 0.6, 1.0 or 3.125).\n'
@ -52,7 +54,7 @@ class TclCommandMillSlots(TclCommandSignaled):
'As a precaution you can enclose them with quotes.'),
('tooldia', 'Diameter of the milling tool (example: 0.1).'),
('outname', 'Name of object to be created holding the milled geometries.'),
('use_thread', 'If to use multithreading: True or False.'),
('use_thread', 'If to use multithreading: True (1) or False (0).'),
('diatol', 'Tolerance. Percentange (0.0 ... 100.0) within which dias in milled_dias will be judged to be '
'the same as the ones in the tools from the Excellon object. E.g: if in milled_dias we have a '
'diameter with value 1.0, in the Excellon we have a tool with dia = 1.05 and we set a tolerance '
@ -84,12 +86,14 @@ class TclCommandMillSlots(TclCommandSignaled):
args['outname'] = name + "_mill_slots"
if 'use_thread' in args:
args['use_thread'] = bool(args['use_thread'])
args['use_thread'] = bool(eval(args['use_thread']))
else:
args['use_thread'] = False
if not obj.slots:
self.raise_tcl_error("The Excellon object has no slots: %s" % name)
units = self.app.defaults['units'].upper()
# units = self.app.defaults['units'].upper()
try:
if 'milled_dias' in args and args['milled_dias'] != 'all':
diameters = [x.strip() for x in args['milled_dias'].split(",")]

View File

@ -13,6 +13,8 @@ class TclCommandMirror(TclCommandSignaled):
# old names for backward compatibility (add_poly, add_polygon)
aliases = ['mirror']
description = '%s %s' % ("--", "Will mirror the geometry of a named object. Does not create a new object.")
# Dictionary of types from Tcl command, needs to be ordered.
# For positional arguments
arg_names = collections.OrderedDict([
@ -32,7 +34,7 @@ class TclCommandMirror(TclCommandSignaled):
# structured help for current command, args needs to be ordered
help = {
'main': "Will mirror an named object.",
'main': "Will mirror the geometry of a named object. Does not create a new object.",
'args': collections.OrderedDict([
('name', 'Name of the object (Gerber, Geometry or Excellon) to be mirrored. Required.'),
('axis', 'Mirror axis parallel to the X or Y axis.'),

View File

@ -11,6 +11,8 @@ class TclCommandNew(TclCommand):
# array of all command aliases, to be able use old names for backward compatibility (add_poly, add_polygon)
aliases = ['new']
description = '%s %s' % ("--", "Starts a new project. Clears objects from memory.")
# dictionary of types from Tcl command, needs to be ordered
arg_names = collections.OrderedDict()

View File

@ -18,6 +18,8 @@ class TclCommandNewExcellon(TclCommandSignaled):
# array of all command aliases, to be able use old names for backward compatibility (add_poly, add_polygon)
aliases = ['new_excellon']
description = '%s %s' % ("--", "Creates a new empty Excellon object.")
# Dictionary of types from Tcl command, needs to be ordered.
# For positional arguments
arg_names = collections.OrderedDict([

View File

@ -11,6 +11,8 @@ class TclCommandNewGeometry(TclCommandSignaled):
# array of all command aliases, to be able use old names for backward compatibility (add_poly, add_polygon)
aliases = ['new_geometry']
description = '%s %s' % ("--", "Creates a new empty Geometry object.")
# Dictionary of types from Tcl command, needs to be ordered.
# For positional arguments
arg_names = collections.OrderedDict([

View File

@ -18,6 +18,8 @@ class TclCommandNewGerber(TclCommandSignaled):
# array of all command aliases, to be able use old names for backward compatibility (add_poly, add_polygon)
aliases = ['new_gerber']
description = '%s %s' % ("--", "Creates a new empty Gerber object.")
# Dictionary of types from Tcl command, needs to be ordered.
# For positional arguments
arg_names = collections.OrderedDict([

View File

@ -22,6 +22,8 @@ class TclCommandNregions(TclCommand):
# array of all command aliases, to be able use old names for backward compatibility (add_poly, add_polygon)
aliases = ['non_copper_regions', 'ncr']
description = '%s %s' % ("--", "Creates a Geometry object with the non-copper regions.")
# dictionary of types from Tcl command, needs to be ordered
arg_names = collections.OrderedDict([
('name', str)
@ -31,7 +33,7 @@ class TclCommandNregions(TclCommand):
option_types = collections.OrderedDict([
('outname', str),
('margin', float),
('rounded', bool)
('rounded', str)
])
# array of mandatory options for current Tcl command: required = {'name','outname'}
@ -39,13 +41,13 @@ class TclCommandNregions(TclCommand):
# structured help for current command, args needs to be ordered
help = {
'main': "Creates a geometry object with the non-copper regions.",
'main': "Creates a Geometry object with the non-copper regions.",
'args': collections.OrderedDict([
('name', 'Object name for which to create non-copper regions. String. Required.'),
('outname', 'Name of the resulting Geometry object. String.'),
('margin', "Specify the edge of the PCB by drawing a box around all objects with this minimum distance. "
"Float number."),
('rounded', "Resulting geometry will have rounded corners. True or False.")
('rounded', "Resulting geometry will have rounded corners. True (1) or False (0).")
]),
'examples': ['ncr name -margin 0.1 -rounded True -outname name_ncr']
}
@ -78,7 +80,7 @@ class TclCommandNregions(TclCommand):
if 'rounded' not in args:
args['rounded'] = self.app.defaults["gerber_noncopperrounded"]
rounded = bool(args['rounded'])
rounded = bool(eval(args['rounded']))
del args['name']

View File

@ -14,6 +14,8 @@ class TclCommandOffset(TclCommand):
# List of all command aliases, to be able use old names for backward compatibility (add_poly, add_polygon)
aliases = ['offset']
description = '%s %s' % ("--", "Will offset the geometry of a named object. Does not create a new object.")
# Dictionary of types from Tcl command, needs to be ordered
arg_names = collections.OrderedDict([
('name', str),

View File

@ -11,6 +11,8 @@ class TclCommandOpenExcellon(TclCommandSignaled):
# array of all command aliases, to be able use old names for backward compatibility (add_poly, add_polygon)
aliases = ['open_excellon']
description = '%s %s' % ("--", "Opens an Excellon file, parse it and create a Excellon object from it.")
# Dictionary of types from Tcl command, needs to be ordered.
# For positional arguments
arg_names = collections.OrderedDict([
@ -28,7 +30,7 @@ class TclCommandOpenExcellon(TclCommandSignaled):
# structured help for current command, args needs to be ordered
help = {
'main': "Opens an Excellon file.",
'main': "Opens an Excellon file, parse it and create a Excellon object from it.",
'args': collections.OrderedDict([
('filename', 'Absolute path to file to open. Required.\n'
'WARNING: no spaces are allowed. If unsure enclose the entire path with quotes.'),

View File

@ -12,6 +12,8 @@ class TclCommandOpenGCode(TclCommandSignaled):
# backward compatibility (add_poly, add_polygon)
aliases = ['open_gcode']
description = '%s %s' % ("--", "Opens an GCode file, parse it and create a GCode object from it.")
# Dictionary of types from Tcl command, needs to be ordered.
# For positional arguments
arg_names = collections.OrderedDict([
@ -29,7 +31,7 @@ class TclCommandOpenGCode(TclCommandSignaled):
# structured help for current command, args needs to be ordered
help = {
'main': "Opens a G-Code file.",
'main': "Opens an GCode file, parse it and create a GCode object from it.",
'args': collections.OrderedDict([
('filename', 'Absolute path to file to open. Required.\n'
'WARNING: no spaces are allowed. If unsure enclose the entire path with quotes.'),

View File

@ -13,6 +13,8 @@ class TclCommandOpenGerber(TclCommandSignaled):
# array of all command aliases, to be able use old names for backward compatibility (add_poly, add_polygon)
aliases = ['open_gerber']
description = '%s %s' % ("--", "Opens an Gerber file, parse it and create a Gerber object from it.")
# dictionary of types from Tcl command, needs to be ordered
arg_names = collections.OrderedDict([
('filename', str)

View File

@ -11,6 +11,8 @@ class TclCommandOpenProject(TclCommandSignaled):
# array of all command aliases, to be able use old names for backward compatibility (add_poly, add_polygon)
aliases = ['open_project']
description = '%s %s' % ("--", "Opens an FlatCAm project file, parse it and recreate all the objects.")
# Dictionary of types from Tcl command, needs to be ordered.
# For positional arguments
arg_names = collections.OrderedDict([
@ -28,7 +30,7 @@ class TclCommandOpenProject(TclCommandSignaled):
# structured help for current command, args needs to be ordered
help = {
'main': "Opens a FlatCAM project.",
'main': "Opens an FlatCAm project file, parse it and recreate all the objects.",
'args': collections.OrderedDict([
('filename', 'Absolute path to file to open. Required.\n'
'WARNING: no spaces are allowed. If unsure enclose the entire path with quotes.'),

View File

@ -11,6 +11,9 @@ class TclCommandOptions(TclCommandSignaled):
# array of all command aliases, to be able use old names for backward compatibility (add_poly, add_polygon)
aliases = ['options']
description = '%s %s' % ("--", "Will return the options (settings) for an object as a string "
"with values separated by \\n.")
# Dictionary of types from Tcl command, needs to be ordered.
# For positional arguments
arg_names = collections.OrderedDict([

View File

@ -22,6 +22,8 @@ class TclCommandPaint(TclCommand):
# Array of all command aliases, to be able use old names for backward compatibility (add_poly, add_polygon)
aliases = ['paint']
description = '%s %s' % ("--", "Paint polygons in the specified object by covering them with toolpaths.")
# dictionary of types from Tcl command, needs to be ordered
arg_names = collections.OrderedDict([
('name', str),
@ -34,12 +36,12 @@ class TclCommandPaint(TclCommand):
('order', str),
('margin', float),
('method', str),
('connect', bool),
('contour', bool),
('connect', str),
('contour', str),
('all', bool),
('single', bool),
('ref', bool),
('all', str),
('single', str),
('ref', str),
('box', str),
('x', float),
('y', float),
@ -51,7 +53,7 @@ class TclCommandPaint(TclCommand):
# structured help for current command, args needs to be ordered
help = {
'main': "Paint polygons",
'main': "Paint polygons in the specified object by covering them with toolpaths.",
'args': collections.OrderedDict([
('name', 'Name of the source Geometry object. String.'),
('tooldia', 'Diameter of the tool to be used. Can be a comma separated list of diameters. No space is '
@ -65,11 +67,12 @@ class TclCommandPaint(TclCommand):
'"fwd" -> tools are ordered from smallest to biggest.'
'"rev" -> tools are ordered from biggest to smallest.'),
('method', 'Algorithm for painting. Can be: "standard", "seed" or "lines".'),
('connect', 'Draw lines to minimize tool lifts. True or False'),
('contour', 'Cut around the perimeter of the painting. True or False'),
('all', 'Paint all polygons in the object. True or False'),
('single', 'Paint a single polygon specified by "x" and "y" parameters. True or False'),
('ref', 'Paint all polygons within a specified object with the name in "box" parameter. True or False'),
('connect', 'Draw lines to minimize tool lifts. True (1) or False (0)'),
('contour', 'Cut around the perimeter of the painting. True (1) or False (0)'),
('all', 'Paint all polygons in the object. True (1) or False (0)'),
('single', 'Paint a single polygon specified by "x" and "y" parameters. True (1) or False (0)'),
('ref', 'Paint all polygons within a specified object with the name in "box" parameter. '
'True (1) or False (0)'),
('box', 'name of the object to be used as paint reference when selecting "ref"" True. String.'),
('x', 'X value of coordinate for the selection of a single polygon. Float number.'),
('y', 'Y value of coordinate for the selection of a single polygon. Float number.'),
@ -124,12 +127,12 @@ class TclCommandPaint(TclCommand):
method = str(self.app.defaults["tools_paintmethod"])
if 'connect' in args:
connect = bool(args['connect'])
connect = bool(eval(args['connect']))
else:
connect = eval(str(self.app.defaults["tools_pathconnect"]))
if 'contour' in args:
contour = bool(args['contour'])
contour = bool(eval(args['contour']))
else:
contour = eval(str(self.app.defaults["tools_paintcontour"]))
@ -199,7 +202,7 @@ class TclCommandPaint(TclCommand):
return "Object not found: %s" % name
# Paint all polygons in the painted object
if 'all' in args and bool(args['all']) is True:
if 'all' in args and bool(eval(args['all'])) is True:
self.app.paint_tool.paint_poly_all(obj=obj,
tooldia=tooldia,
overlap=overlap,
@ -215,7 +218,7 @@ class TclCommandPaint(TclCommand):
return
# Paint single polygon in the painted object
elif 'single' in args and bool(args['single']) is True:
elif 'single' in args and bool(eval(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:
@ -238,7 +241,7 @@ class TclCommandPaint(TclCommand):
return
# Paint all polygons found within the box object from the the painted object
elif 'ref' in args and bool(args['ref']) is True:
elif 'ref' in args and bool(eval(args['ref'])) is True:
if 'box' not in args:
self.raise_tcl_error('%s' % _("Expected -box <value>."))
else:

View File

@ -19,7 +19,10 @@ class TclCommandPanelize(TclCommand):
"""
# List of all command aliases, to be able use old names for backward compatibility (add_poly, add_polygon)
aliases = ['panelize','pan', 'panel']
aliases = ['panelize', 'pan', 'panel']
description = '%s %s' % ("--", "Create a new object with an array of duplicates of the original geometry, "
"arranged in a grid.")
# Dictionary of types from Tcl command, needs to be ordered
arg_names = collections.OrderedDict([
@ -34,7 +37,7 @@ class TclCommandPanelize(TclCommand):
('spacing_rows', float),
('box', str),
('outname', str),
('run_threaded', bool)
('run_threaded', str)
])
# array of mandatory options for current Tcl command: required = {'name','outname'}
@ -42,7 +45,7 @@ class TclCommandPanelize(TclCommand):
# structured help for current command, args needs to be ordered
help = {
'main': 'Rectangular panelizing.',
'main': 'Create a new object with an array of duplicates of the original geometry, arranged in a grid.',
'args': collections.OrderedDict([
('name', 'Name of the object to panelize.'),
('box', 'Name of object which acts as box (cutout for example.)'
@ -52,7 +55,7 @@ class TclCommandPanelize(TclCommand):
('columns', 'Number of columns.'),
('rows', 'Number of rows;'),
('outname', 'Name of the new geometry object.'),
('run_threaded', 'False = non-threaded || True = threaded')
('run_threaded', 'False (0) = non-threaded execution or True (1) = threaded execution')
]),
'examples': [
'panelize obj_name',
@ -77,7 +80,7 @@ class TclCommandPanelize(TclCommand):
# Get source object.
try:
obj = self.app.collection.get_by_name(str(name))
except Exception as e:
except Exception:
return "Could not retrieve object: %s" % name
if obj is None:
@ -111,7 +114,7 @@ class TclCommandPanelize(TclCommand):
outname = name + '_panelized'
if 'run_threaded' in args:
threaded = bool(args['run_threaded'])
threaded = bool(eval(args['run_threaded']))
else:
threaded = False

View File

@ -14,6 +14,8 @@ class TclCommandPlotAll(TclCommand):
# List of all command aliases, to be able use old names for backward compatibility (add_poly, add_polygon)
aliases = ['plot_all']
description = '%s %s' % ("--", "Plots all objects on GUI.")
# Dictionary of types from Tcl command, needs to be ordered
arg_names = collections.OrderedDict([
@ -29,7 +31,7 @@ class TclCommandPlotAll(TclCommand):
# structured help for current command, args needs to be ordered
help = {
'main': "Updates the plot on the user interface.",
'main': "Plots all objects on GUI.",
'args': collections.OrderedDict([
]),

View File

@ -21,6 +21,8 @@ class TclCommandPlotObjects(TclCommand):
# List of all command aliases, to be able use old names for backward compatibility (add_poly, add_polygon)
aliases = ['plot_objects']
description = '%s %s' % ("--", "Plot a specified list of objects in GUI.")
# Dictionary of types from Tcl command, needs to be ordered
arg_names = collections.OrderedDict([
('names', str)
@ -36,11 +38,12 @@ class TclCommandPlotObjects(TclCommand):
# structured help for current command, args needs to be ordered
help = {
'main': "Plot a list of objects.",
'main': "Plot a specified list of objects in GUI.",
'args': collections.OrderedDict([
('names', "A list of object names to be plotted separated by comma. Required.")
('names', "A list of object names to be plotted separated by comma. Required.\n"
"WARNING: no spaces are allowed. If unsure enclose the entire list with quotes.")
]),
'examples': ["plot_objects gerber_obj.GRB, excellon_obj.DRL"]
'examples': ["plot_objects gerber_obj.GRB,excellon_obj.DRL"]
}
def execute(self, args, unnamed_args):

View File

@ -21,6 +21,8 @@ class TclCommandQuit(TclCommand):
# List of all command aliases, to be able use old names for backward compatibility (add_poly, add_polygon)
aliases = ['quit_flatcam']
description = '%s %s' % ("--", "Tcl shell command to quit FlatCAM from Tcl shell.")
# Dictionary of types from Tcl command, needs to be ordered
arg_names = collections.OrderedDict([

View File

@ -11,6 +11,8 @@ class TclCommandSaveProject(TclCommandSignaled):
# array of all command aliases, to be able use old names for backward compatibility (add_poly, add_polygon)
aliases = ['save_project']
description = '%s %s' % ("--", "Saves the FlatCAM project to file.")
# Dictionary of types from Tcl command, needs to be ordered.
# For positional arguments
arg_names = collections.OrderedDict([
@ -30,7 +32,7 @@ class TclCommandSaveProject(TclCommandSignaled):
help = {
'main': "Saves the FlatCAM project to file.",
'args': collections.OrderedDict([
('filename', 'Absolute path to file to open. Required.\n'
('filename', 'Absolute path to file to save. Required.\n'
'WARNING: no spaces are allowed. If unsure enclose the entire path with quotes.'),
]),
'examples': ['save_project D:\\my_project_file.FlatPrj',

View File

@ -16,6 +16,8 @@ class TclCommandSaveSys(TclCommandSignaled):
# array of all command aliases, to be able use old names for backward compatibility (add_poly, add_polygon)
aliases = ['save_sys', 'save']
description = '%s %s' % ("--", "Saves the FlatCAM system parameters to defaults file.")
# Dictionary of types from Tcl command, needs to be ordered.
# For positional arguments
arg_names = collections.OrderedDict([

View File

@ -25,6 +25,8 @@ class TclCommandScale(TclCommand):
# List of all command aliases, to be able use old names for backward compatibility (add_poly, add_polygon)
aliases = ['scale']
description = '%s %s' % ("--", "Will scale the geometry of a named object. Does not create a new object.")
# Dictionary of types from Tcl command, needs to be ordered
arg_names = collections.OrderedDict([
('name', str),

View File

@ -14,6 +14,8 @@ class TclCommandSetActive(TclCommand):
# List of all command aliases, to be able use old names for backward compatibility (add_poly, add_polygon)
aliases = ['set_active']
description = '%s %s' % ("--", "Sets a FlatCAM object as active (selected).")
# Dictionary of types from Tcl command, needs to be ordered
arg_names = collections.OrderedDict([
('name', str),
@ -29,7 +31,7 @@ class TclCommandSetActive(TclCommand):
# structured help for current command, args needs to be ordered
help = {
'main': 'Sets an object as active.',
'main': 'Sets a FlatCAM object as active (selected).',
'args': collections.OrderedDict([
('name', 'Name of the FlatCAM object to be set as active (selected). Required.'),
]),

View File

@ -34,6 +34,8 @@ class TclCommandSetOrigin(TclCommand):
# List of all command aliases, to be able use old names for backward compatibility (add_poly, add_polygon)
aliases = ['set_origin', 'origin']
description = '%s %s' % ("--", "Set the origin at the specified x,y location.")
# Dictionary of types from Tcl command, needs to be ordered
arg_names = collections.OrderedDict([
('loc', str)
@ -41,7 +43,7 @@ class TclCommandSetOrigin(TclCommand):
# Dictionary of types from Tcl command, needs to be ordered , this is for options like -optionname value
option_types = collections.OrderedDict([
('auto', bool)
('auto', str)
])
# array of mandatory options for current Tcl command: required = {'name','outname'}
@ -55,7 +57,7 @@ class TclCommandSetOrigin(TclCommand):
('loc', 'Location to offset all the selected objects. NO SPACES ALLOWED in X and Y pair.\n'
'Use like this: 2,3'),
('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.')
'-auto=True is not correct but -auto 1 or -auto True is correct. True (1) or False (0).')
]),
'examples': ['set_origin 3,2', 'set_origin -auto 1', 'origin']
}

View File

@ -14,6 +14,8 @@ class TclCommandSetSys(TclCommand):
# List of all command aliases, to be able use old names for backward compatibility (add_poly, add_polygon)
aliases = ['set_sys', 'setsys']
description = '%s %s' % ("--", "Sets the value of the specified system variable.")
# Dictionary of types from Tcl command, needs to be ordered
arg_names = collections.OrderedDict([
('name', str),
@ -30,7 +32,7 @@ class TclCommandSetSys(TclCommand):
# structured help for current command, args needs to be ordered
help = {
'main': "Sets the value of the system variable.",
'main': "Sets the value of the specified system variable.",
'args': collections.OrderedDict([
('name', 'Name of the system variable. Required.'),
('value', 'Value to set.')

View File

@ -14,6 +14,8 @@ class TclCommandSkew(TclCommand):
# List of all command aliases, to be able use old names for backward compatibility (add_poly, add_polygon)
aliases = ['skew']
description = '%s %s' % ("--", "Will deform (skew) the geometry of a named object. Does not create a new object.")
# Dictionary of types from Tcl command, needs to be ordered
arg_names = collections.OrderedDict([
('name', str),
@ -30,7 +32,7 @@ class TclCommandSkew(TclCommand):
# structured help for current command, args needs to be ordered
help = {
'main': "Shear/Skew an object by angles along x and y dimensions. The reference point is the left corner of "
'main': "Shear/Skew an object along x and y dimensions. The reference point is the left corner of "
"the bounding box of the object.",
'args': collections.OrderedDict([
('name', 'Name of the object (Gerber, Geometry or Excellon) to be deformed (skewed). Required.'),

View File

@ -11,6 +11,9 @@ class TclCommandSubtractPoly(TclCommandSignaled):
# array of all command aliases, to be able use old names for backward compatibility (add_poly, add_polygon)
aliases = ['subtract_poly']
description = '%s %s' % ("--", "Subtract polygon from the given Geometry object. "
"The coordinates are provided in X Y pairs.")
# Dictionary of types from Tcl command, needs to be ordered.
# For positional arguments
arg_names = collections.OrderedDict([

View File

@ -19,6 +19,9 @@ class TclCommandSubtractRectangle(TclCommandSignaled):
# array of all command aliases, to be able use old names for backward compatibility (add_poly, add_polygon)
aliases = ['subtract_rectangle']
description = '%s %s' % ("--", "Subtract a rectangle from the given Geometry object. "
"The coordinates are provided in X Y pairs.")
# Dictionary of types from Tcl command, needs to be ordered.
# For positional arguments
arg_names = collections.OrderedDict([

View File

@ -14,6 +14,8 @@ class TclCommandVersion(TclCommand):
# List of all command aliases, to be able use old names for backward compatibility (add_poly, add_polygon)
aliases = ['version']
description = '%s %s' % ("--", "Checks the program version.")
# Dictionary of types from Tcl command, needs to be ordered
arg_names = collections.OrderedDict([

View File

@ -12,6 +12,8 @@ class TclCommandWriteGCode(TclCommandSignaled):
# old names for backward compatibility (add_poly, add_polygon)
aliases = ['write_gcode']
description = '%s %s' % ("--", "Saves G-code of a CNC Job object to file.")
# Dictionary of types from Tcl command, needs to be ordered.
# For positional arguments
arg_names = collections.OrderedDict([
@ -24,7 +26,7 @@ class TclCommandWriteGCode(TclCommandSignaled):
option_types = collections.OrderedDict([
('preamble', str),
('postamble', str),
('muted', int)
('muted', str)
])
# array of mandatory options for current Tcl command: required = {'name','outname'}
@ -38,7 +40,7 @@ class TclCommandWriteGCode(TclCommandSignaled):
('filename', 'Output filename. Required.'),
('preamble', 'Text to append at the beginning.'),
('postamble', 'Text to append at the end.'),
('muted', 'It will not put errors in the Shell or status bar.')
('muted', 'It will not put errors in the Shell or status bar. True (1) or False (0)')
]),
'examples': ["write_gcode name c:\\\\gcode_repo"]
@ -67,9 +69,9 @@ class TclCommandWriteGCode(TclCommandSignaled):
postamble = args['postamble'] if 'postamble' in args else ''
if 'muted' in args:
muted = args['muted']
muted = bool(eval(args['muted']))
else:
muted = 0
muted = False
# TODO: This is not needed any more? All targets should be present.
# If there are promised objects, wait until all promises have been fulfilled.
@ -91,7 +93,7 @@ class TclCommandWriteGCode(TclCommandSignaled):
try:
obj = self.app.collection.get_by_name(str(obj_name))
except Exception:
if muted == 0:
if muted is False:
return "Could not retrieve object: %s" % obj_name
else:
return "fail"
@ -99,7 +101,7 @@ class TclCommandWriteGCode(TclCommandSignaled):
try:
obj.export_gcode(str(filename), str(preamble), str(postamble))
except Exception as e:
if not muted:
if muted is False:
return "Operation failed: %s" % str(e)
else:
return

View File

@ -99,7 +99,12 @@ def register_all_commands(app, commands):
command_instance = class_type(app)
for alias in command_instance.aliases:
try:
description = command_instance.description
except AttributeError:
description = ''
commands[alias] = {
'fcn': command_instance.execute_wrapper,
'help': command_instance.get_decorated_help()
'help': command_instance.get_decorated_help(),
'description': description
}