- added 3 new tcl commands: export dxf, export excellon and export gerber

This commit is contained in:
Marius Stanciu 2019-12-02 20:54:18 +02:00 committed by Marius
parent 80dcd3805a
commit c439009251
7 changed files with 160 additions and 3 deletions

View File

@ -2097,7 +2097,8 @@ class App(QtCore.QObject):
# #####################################################################################
self.tcl_commands_list = ['add_circle', 'add_poly', 'add_polygon', 'add_polyline', 'add_rectangle',
'aligndrill', 'aligndrillgrid', 'bbox', 'bounding_box', 'clear', 'cncjob', 'cutout',
'delete', 'drillcncjob', 'export_gcode', 'export_svg', 'ext', 'exteriors', 'follow',
'delete', 'drillcncjob', 'export_dxf', 'edxf', 'export_excellon', 'ee', 'export_exc',
'export_gcode', 'export_gerber', 'egr', 'export_svg', 'ext', 'exteriors', 'follow',
'geo_union', 'geocutout', 'get_names', 'get_sys', 'getsys', 'help', 'import_svg',
'interiors', 'isolate', 'join_excellon', 'join_excellons', 'join_geometries',
'join_geometry', 'list_sys', 'listsys', 'milld', 'mills', 'milldrills', 'millslots',
@ -10131,7 +10132,7 @@ class App(QtCore.QObject):
self.report_usage("export_excellon()")
if filename is None:
filename = self.defaults["global_last_save_folder"]
filename = self.defaults["global_last_save_folder"] + '/' + 'exported_excellon'
self.log.debug("export_excellon()")
@ -10148,6 +10149,11 @@ class App(QtCore.QObject):
else:
obj = local_use
if not isinstance(obj, FlatCAMExcellon):
self.inform.emit('[ERROR_NOTCL] %s' %
_("Failed. Only Excellon objects can be saved as Excellon files..."))
return
# updated units
eunits = self.defaults["excellon_exp_units"]
ewhole = self.defaults["excellon_exp_integer"]

View File

@ -2334,7 +2334,7 @@ class FlatCAMExcellon(FlatCAMObj, Excellon):
def build_ui(self):
FlatCAMObj.build_ui(self)
self.units = self.app.udefaults['units'].upper()
self.units = self.app.defaults['units'].upper()
try:
# if connected, disconnect the signal from the slot on item_changed as it creates issues

View File

@ -14,6 +14,7 @@ CAD program, and create G-Code for Isolation routing.
- fixed issue #343; updated the Image Tool
- improvements in Importing SVG as Gerber - added an automatic source generation (it is not infallible)
- a hack to import correctly the QRCode exported as SVG from FlatCAM
- added 3 new tcl commands: export dxf, export excellon and export gerber
28.11.2019

View File

@ -0,0 +1,49 @@
from tclCommands.TclCommand import TclCommand
import collections
class TclCommandExportDXF(TclCommand):
"""
Tcl shell command to export a Geometry Object as an DXF File.
example:
export_dxf path/my_geometry filename
"""
# List of all command aliases, to be able use old names for backward compatibility (add_poly, add_polygon)
aliases = ['export_dxf', 'edxf']
# Dictionary of types from Tcl command, needs to be ordered
arg_names = collections.OrderedDict([
('obj_name', str),
('filename', str)
])
# Dictionary of types from Tcl command, needs to be ordered , this is for options like -optionname value
option_types = collections.OrderedDict([
])
# array of mandatory options for current Tcl command: required = ['name','outname']
required = ['obj_name']
# structured help for current command, args needs to be ordered
help = {
'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.')
]),
'examples': ['export_dxf my_geo path/my_file.dxf']
}
def execute(self, args, unnamed_args):
"""
:param args:
: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)

View File

@ -0,0 +1,49 @@
from tclCommands.TclCommand import TclCommand
import collections
class TclCommandExportExcellon(TclCommand):
"""
Tcl shell command to export a Excellon Object as an Excellon File.
example:
export_exc path/my_excellon filename
"""
# List of all command aliases, to be able use old names for backward compatibility (add_poly, add_polygon)
aliases = ['export_exc', 'ee', 'export_excellon']
# Dictionary of types from Tcl command, needs to be ordered
arg_names = collections.OrderedDict([
('obj_name', str),
('filename', str)
])
# Dictionary of types from Tcl command, needs to be ordered , this is for options like -optionname value
option_types = collections.OrderedDict([
])
# array of mandatory options for current Tcl command: required = ['name','outname']
required = ['obj_name']
# structured help for current command, args needs to be ordered
help = {
'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.')
]),
'examples': ['export_excellon my_excellon path/my_file.drl']
}
def execute(self, args, unnamed_args):
"""
:param args:
: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)

View File

@ -0,0 +1,49 @@
from tclCommands.TclCommand import TclCommand
import collections
class TclCommandExportGerber(TclCommand):
"""
Tcl shell command to export a Gerber Object as an Gerber File.
example:
export_exc path/my_excellon filename
"""
# List of all command aliases, to be able use old names for backward compatibility (add_poly, add_polygon)
aliases = ['export_grb', 'egr', 'export_gerber']
# Dictionary of types from Tcl command, needs to be ordered
arg_names = collections.OrderedDict([
('obj_name', str),
('filename', str)
])
# Dictionary of types from Tcl command, needs to be ordered , this is for options like -optionname value
option_types = collections.OrderedDict([
])
# array of mandatory options for current Tcl command: required = ['name','outname']
required = ['obj_name']
# structured help for current command, args needs to be ordered
help = {
'main': "Export a Gerber Object as a Gerber File.",
'args': collections.OrderedDict([
('obj_name', 'Name of the object to export.'),
('filename', 'Path to the file to export.')
]),
'examples': ['export_gerber my_gerber path/my_file.gbr']
}
def execute(self, args, unnamed_args):
"""
:param args:
:param unnamed_args:
:return:
"""
if 'filename' not in args:
args['filename'] = self.app.defaults["global_last_save_folder"] + '/' + args['obj_name']
self.app.export_gerber(use_thread=False,**args)

View File

@ -17,6 +17,9 @@ import tclCommands.TclCommandCopperClear
import tclCommands.TclCommandCutout
import tclCommands.TclCommandDelete
import tclCommands.TclCommandDrillcncjob
import tclCommands.TclCommandExportDXF
import tclCommands.TclCommandExportExcellon
import tclCommands.TclCommandExportGerber
import tclCommands.TclCommandExportGcode
import tclCommands.TclCommandExportSVG
import tclCommands.TclCommandExteriors