- modified the TCL comamand follow to the new architecture. Tested it and

it works without crashes. It can be safely pulled in.
This commit is contained in:
Marius Stanciu 2018-05-31 02:09:15 +03:00
parent 98c5460876
commit c67d2f0028
3 changed files with 91 additions and 28 deletions

View File

@ -3632,27 +3632,27 @@ class App(QtCore.QObject):
return output
def follow(obj_name, *args):
a, kwa = h(*args)
types = {'outname': str}
for key in kwa:
if key not in types:
return 'Unknown parameter: %s' % key
kwa[key] = types[key](kwa[key])
try:
obj = self.collection.get_by_name(str(obj_name))
except:
return "Could not retrieve object: %s" % obj_name
if obj is None:
return "Object not found: %s" % obj_name
try:
obj.follow(**kwa)
except Exception, e:
return "ERROR: %s" % str(e)
# def follow(obj_name, *args):
# a, kwa = h(*args)
#
# types = {'outname': str}
#
# for key in kwa:
# if key not in types:
# return 'Unknown parameter: %s' % key
# kwa[key] = types[key](kwa[key])
#
# try:
# obj = self.collection.get_by_name(str(obj_name))
# except:
# return "Could not retrieve object: %s" % obj_name
# if obj is None:
# return "Object not found: %s" % obj_name
#
# try:
# obj.follow(**kwa)
# except Exception, e:
# return "ERROR: %s" % str(e)
# def get_sys(param):
# if param in self.defaults:
@ -4096,13 +4096,13 @@ class App(QtCore.QObject):
'fcn': make_docs,
'help': 'Prints command rererence in reStructuredText format.'
},
'follow': {
'fcn': follow,
'help': 'Creates a geometry object following gerber paths.\n' +
'> follow <name> [-outname <oname>]\n' +
' name: Name of the gerber object.\n' +
' outname: Name of the output geometry object.'
},
# 'follow': {
# 'fcn': follow,
# 'help': 'Creates a geometry object following gerber paths.\n' +
# '> follow <name> [-outname <oname>]\n' +
# ' name: Name of the gerber object.\n' +
# ' outname: Name of the output geometry object.'
# },
# 'get_sys': {
# 'fcn': get_sys,

View File

@ -0,0 +1,62 @@
from ObjectCollection import *
import TclCommand
class TclCommandFollow(TclCommand.TclCommandSignaled):
"""
Tcl shell command to follow a Gerber file
"""
# array of all command aliases, to be able use old names for backward compatibility (add_poly, add_polygon)
aliases = ['follow']
# dictionary of types from Tcl command, needs to be ordered
arg_names = collections.OrderedDict([
('name', str)
])
# dictionary of types from Tcl command, needs to be ordered , this is for options like -optionname value
option_types = collections.OrderedDict([
('outname', str)
])
# array of mandatory options for current Tcl command: required = {'name','outname'}
required = ['name']
# structured help for current command, args needs to be ordered
help = {
'main': "Creates a geometry object following gerber paths.",
'args': collections.OrderedDict([
('name', 'Object name to follow.'),
('outname', 'Name of the resulting Geometry object.')
]),
'examples': ['follow name -outname name_follow']
}
def execute(self, args, unnamed_args):
"""
execute current TCL shell command
:param args: array of known named arguments and options
:param unnamed_args: array of other values which were passed into command
without -somename and we do not have them in known arg_names
:return: None or exception
"""
name = args['name']
if 'outname' not in args:
follow_name = name + "_follow"
obj = self.app.collection.get_by_name(name)
if obj is None:
self.raise_tcl_error("Object not found: %s" % name)
if not isinstance(obj, FlatCAMGerber):
self.raise_tcl_error('Expected FlatCAMGerber, got %s %s.' % (name, type(obj)))
del args['name']
obj.follow(**args)

View File

@ -16,6 +16,7 @@ import tclCommands.TclCommandDrillcncjob
import tclCommands.TclCommandExportGcode
import tclCommands.TclCommandExportSVG
import tclCommands.TclCommandExteriors
import tclCommands.TclCommandFollow
import tclCommands.TclCommandGeoCutout
import tclCommands.TclCommandGeoUnion
import tclCommands.TclCommandGetNames