- added ability for Tcl commands to have optional arguments with None value (meaning missing value). This case should be treated for each Tcl command in execute() method

This commit is contained in:
Marius Stanciu 2020-01-01 22:24:43 +02:00 committed by Marius
parent 0447839e43
commit b5d69f493d
2 changed files with 21 additions and 7 deletions

View File

@ -17,6 +17,7 @@ CAD program, and create G-Code for Isolation routing.
- in NCC Tool I've added a warning so the user is warned that the NCC margin has to have a value of at least the tool diameter that is doing an iso_op job in the Tool Table
- modified the Drillcncjob and Cncjob Tcl commands to be allowed to work without the 'dwell' and 'toolchange' arguments. If 'dwelltime' argument is present it will be assumed that the 'dwell' is True and the same for 'toolchangez' parameter, if present then 'toolchange' will be assumed to be True, else False
- modified the extracut and multidepth parameters in Cncjob Tcl command like for dwell and toolchange
- added ability for Tcl commands to have optional arguments with None value (meaning missing value). This case should be treated for each Tcl command in execute() method
30.12.2019

View File

@ -177,19 +177,26 @@ class TclCommand(object):
arguments = []
n = len(args)
name = None
option_name = None
for i in range(n):
match = re.search(r'^-([a-zA-Z].*)', args[i])
if match:
assert name is None
name = match.group(1)
# assert option_name is None
if option_name is not None:
options[option_name] = None
option_name = match.group(1)
continue
if name is None:
if option_name is None:
arguments.append(args[i])
else:
options[name] = args[i]
name = None
options[option_name] = args[i]
option_name = None
if option_name is not None:
options[option_name] = None
return arguments, options
@ -211,6 +218,7 @@ class TclCommand(object):
for argument in arguments:
if len(self.arg_names) > idx:
key, arg_type = arg_names_items[idx]
try:
named_args[key] = arg_type(argument)
except Exception as e:
@ -226,7 +234,12 @@ class TclCommand(object):
self.raise_tcl_error('Unknown parameter: %s' % key)
try:
if key != 'timeout':
named_args[key] = self.option_types[key](options[key])
# None options are allowed; if None then the defaults are used
# - must be implemented in the Tcl commands
if options[key] is not None:
named_args[key] = self.option_types[key](options[key])
else:
named_args[key] = options[key]
else:
named_args[key] = int(options[key])
except Exception as e: