- 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:
parent
98c5460876
commit
c67d2f0028
|
@ -3632,27 +3632,27 @@ class App(QtCore.QObject):
|
||||||
|
|
||||||
return output
|
return output
|
||||||
|
|
||||||
def follow(obj_name, *args):
|
# def follow(obj_name, *args):
|
||||||
a, kwa = h(*args)
|
# a, kwa = h(*args)
|
||||||
|
#
|
||||||
types = {'outname': str}
|
# types = {'outname': str}
|
||||||
|
#
|
||||||
for key in kwa:
|
# for key in kwa:
|
||||||
if key not in types:
|
# if key not in types:
|
||||||
return 'Unknown parameter: %s' % key
|
# return 'Unknown parameter: %s' % key
|
||||||
kwa[key] = types[key](kwa[key])
|
# kwa[key] = types[key](kwa[key])
|
||||||
|
#
|
||||||
try:
|
# try:
|
||||||
obj = self.collection.get_by_name(str(obj_name))
|
# obj = self.collection.get_by_name(str(obj_name))
|
||||||
except:
|
# except:
|
||||||
return "Could not retrieve object: %s" % obj_name
|
# return "Could not retrieve object: %s" % obj_name
|
||||||
if obj is None:
|
# if obj is None:
|
||||||
return "Object not found: %s" % obj_name
|
# return "Object not found: %s" % obj_name
|
||||||
|
#
|
||||||
try:
|
# try:
|
||||||
obj.follow(**kwa)
|
# obj.follow(**kwa)
|
||||||
except Exception, e:
|
# except Exception, e:
|
||||||
return "ERROR: %s" % str(e)
|
# return "ERROR: %s" % str(e)
|
||||||
|
|
||||||
# def get_sys(param):
|
# def get_sys(param):
|
||||||
# if param in self.defaults:
|
# if param in self.defaults:
|
||||||
|
@ -4096,13 +4096,13 @@ class App(QtCore.QObject):
|
||||||
'fcn': make_docs,
|
'fcn': make_docs,
|
||||||
'help': 'Prints command rererence in reStructuredText format.'
|
'help': 'Prints command rererence in reStructuredText format.'
|
||||||
},
|
},
|
||||||
'follow': {
|
# 'follow': {
|
||||||
'fcn': follow,
|
# 'fcn': follow,
|
||||||
'help': 'Creates a geometry object following gerber paths.\n' +
|
# 'help': 'Creates a geometry object following gerber paths.\n' +
|
||||||
'> follow <name> [-outname <oname>]\n' +
|
# '> follow <name> [-outname <oname>]\n' +
|
||||||
' name: Name of the gerber object.\n' +
|
# ' name: Name of the gerber object.\n' +
|
||||||
' outname: Name of the output geometry object.'
|
# ' outname: Name of the output geometry object.'
|
||||||
},
|
# },
|
||||||
|
|
||||||
# 'get_sys': {
|
# 'get_sys': {
|
||||||
# 'fcn': get_sys,
|
# 'fcn': get_sys,
|
||||||
|
|
|
@ -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)
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,7 @@ import tclCommands.TclCommandDrillcncjob
|
||||||
import tclCommands.TclCommandExportGcode
|
import tclCommands.TclCommandExportGcode
|
||||||
import tclCommands.TclCommandExportSVG
|
import tclCommands.TclCommandExportSVG
|
||||||
import tclCommands.TclCommandExteriors
|
import tclCommands.TclCommandExteriors
|
||||||
|
import tclCommands.TclCommandFollow
|
||||||
import tclCommands.TclCommandGeoCutout
|
import tclCommands.TclCommandGeoCutout
|
||||||
import tclCommands.TclCommandGeoUnion
|
import tclCommands.TclCommandGeoUnion
|
||||||
import tclCommands.TclCommandGetNames
|
import tclCommands.TclCommandGetNames
|
||||||
|
|
Loading…
Reference in New Issue