- fixed the Tcl Command AlignDrill
- fixed the Tcl Command AlignDrillGrid - fixed the Tcl COmmand Panelize, Excellon panelization section - Fixed an issue in Tool Calibration export_excellon method call - PEP8 corrections all over the app
This commit is contained in:
@@ -79,8 +79,7 @@ class TclCommand(object):
|
||||
|
||||
:return: current command
|
||||
"""
|
||||
command_string = []
|
||||
command_string.append(self.aliases[0])
|
||||
command_string = [self.aliases[0]]
|
||||
|
||||
if self.original_args is not None:
|
||||
for arg in self.original_args:
|
||||
@@ -417,7 +416,7 @@ class TclCommandSignaled(TclCommand):
|
||||
# set detail for processing, it will be there until next open or close
|
||||
self.app.shell.open_processing(self.get_current_command())
|
||||
|
||||
def handle_finished(obj):
|
||||
def handle_finished():
|
||||
self.app.shell_command_finished.disconnect(handle_finished)
|
||||
if self.error is not None:
|
||||
self.raise_tcl_unknown_error(self.error)
|
||||
|
||||
@@ -108,8 +108,10 @@ class TclCommandAlignDrill(TclCommandSignaled):
|
||||
|
||||
xscale, yscale = {"X": (1.0, -1.0), "Y": (-1.0, 1.0)}[axis]
|
||||
|
||||
tooldia = args['dia']
|
||||
|
||||
# Tools
|
||||
tools = {"1": {"C": args['dia']}}
|
||||
# tools = {"1": {"C": args['dia']}}
|
||||
|
||||
def alligndrill_init_me(init_obj, app_obj):
|
||||
"""
|
||||
@@ -126,8 +128,8 @@ class TclCommandAlignDrill(TclCommandSignaled):
|
||||
for hole in holes:
|
||||
point = Point(hole)
|
||||
point_mirror = affinity.scale(point, xscale, yscale, origin=(px, py))
|
||||
drills.append({"point": point, "tool": "1"})
|
||||
drills.append({"point": point_mirror, "tool": "1"})
|
||||
drills.append(point)
|
||||
drills.append(point_mirror)
|
||||
else:
|
||||
if 'box' not in args:
|
||||
return "ERROR: -grid can be used only for -box"
|
||||
@@ -167,11 +169,17 @@ class TclCommandAlignDrill(TclCommandSignaled):
|
||||
for hole in localholes:
|
||||
point = Point(hole)
|
||||
point_mirror = affinity.scale(point, xscale, yscale, origin=(px, py))
|
||||
drills.append({"point": point, "tool": "1"})
|
||||
drills.append({"point": point_mirror, "tool": "1"})
|
||||
drills.append(point)
|
||||
drills.append(point_mirror)
|
||||
|
||||
init_obj.tools = {
|
||||
'1': {
|
||||
'tooldia': tooldia,
|
||||
'drills': drills,
|
||||
'solid_geometry': []
|
||||
}
|
||||
}
|
||||
|
||||
init_obj.tools = tools
|
||||
init_obj.drills = drills
|
||||
init_obj.create_geometry()
|
||||
|
||||
# Box
|
||||
|
||||
@@ -80,8 +80,9 @@ class TclCommandAlignDrillGrid(TclCommandSignaled):
|
||||
else:
|
||||
gridoffsety = args['gridoffsety']
|
||||
|
||||
tooldia = args['dia']
|
||||
# Tools
|
||||
tools = {"1": {"C": args['dia']}}
|
||||
# tools = {"1": {"C": args['dia']}}
|
||||
|
||||
def aligndrillgrid_init_me(init_obj, app_obj):
|
||||
"""
|
||||
@@ -101,13 +102,18 @@ class TclCommandAlignDrillGrid(TclCommandSignaled):
|
||||
|
||||
for col in range(args['columns']):
|
||||
point = Point(currentx + gridoffsetx, currenty + gridoffsety)
|
||||
drills.append({"point": point, "tool": "1"})
|
||||
drills.append(point)
|
||||
currentx = currentx + args['gridx']
|
||||
|
||||
currenty = currenty + args['gridy']
|
||||
|
||||
init_obj.tools = tools
|
||||
init_obj.drills = drills
|
||||
init_obj.tools = {
|
||||
'1': {
|
||||
'tooldia': tooldia,
|
||||
'drills': drills,
|
||||
'solid_geometry': []
|
||||
}
|
||||
}
|
||||
init_obj.create_geometry()
|
||||
|
||||
# Create the new object
|
||||
|
||||
@@ -154,7 +154,7 @@ class TclCommandCncjob(TclCommandSignaled):
|
||||
if "dpp" in args:
|
||||
args["multidepth"] = True
|
||||
if args["dpp"] is None:
|
||||
args["dpp"] =self.app.defaults["geometry_depthperpass"]
|
||||
args["dpp"] = self.app.defaults["geometry_depthperpass"]
|
||||
else:
|
||||
args["dpp"] = float(args["dpp"])
|
||||
else:
|
||||
@@ -188,7 +188,7 @@ class TclCommandCncjob(TclCommandSignaled):
|
||||
args["dwell"] = self.app.defaults["geometry_dwell"]
|
||||
args["dwelltime"] = self.app.defaults["geometry_dwelltime"]
|
||||
|
||||
args["pp"] = args["pp"] if "pp" in args and args["pp"] else self.app.defaults["geometry_ppname_g"]
|
||||
args["pp"] = args["pp"] if "pp" in args and args["pp"] else self.app.defaults["geometry_ppname_g"]
|
||||
|
||||
if "toolchangez" in args:
|
||||
args["toolchange"] = True
|
||||
|
||||
@@ -252,7 +252,7 @@ class TclCommandCopperClear(TclCommand):
|
||||
# Non-Copper clear all polygons in the non-copper clear object
|
||||
if 'all' in args:
|
||||
self.app.ncclear_tool.clear_copper_tcl(ncc_obj=obj,
|
||||
select_method=0, # ITSELF
|
||||
select_method=0, # ITSELF
|
||||
ncctooldia=tooldia,
|
||||
overlap=overlap,
|
||||
order=order,
|
||||
@@ -283,7 +283,7 @@ class TclCommandCopperClear(TclCommand):
|
||||
|
||||
self.app.ncclear_tool.clear_copper_tcl(ncc_obj=obj,
|
||||
sel_obj=box_obj,
|
||||
select_method=2, # REFERENCE OBJECT
|
||||
select_method=2, # REFERENCE OBJECT
|
||||
ncctooldia=tooldia,
|
||||
overlap=overlap,
|
||||
order=order,
|
||||
|
||||
@@ -80,5 +80,5 @@ class TclCommandExportGcode(TclCommandSignaled):
|
||||
self.raise_tcl_error('!!!Promises exists, but should not here!!!')
|
||||
|
||||
del args['name']
|
||||
modified_gcode = obj.get_gcode(**args)
|
||||
obj.get_gcode(**args)
|
||||
return
|
||||
|
||||
@@ -49,4 +49,4 @@ class TclCommandExportGerber(TclCommand):
|
||||
"""
|
||||
if 'filename' not in args:
|
||||
args['filename'] = self.app.defaults["global_last_save_folder"] + '/' + args['name']
|
||||
self.app.f_handlers.export_gerber(use_thread=False,**args)
|
||||
self.app.f_handlers.export_gerber(use_thread=False, **args)
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
from tclCommands.TclCommand import TclCommand
|
||||
|
||||
import collections
|
||||
from copy import copy
|
||||
|
||||
|
||||
class TclCommandExportSVG(TclCommand):
|
||||
|
||||
@@ -65,4 +65,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()
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
from tclCommands.TclCommand import TclCommand
|
||||
|
||||
import collections
|
||||
import os
|
||||
import logging
|
||||
import gettext
|
||||
import appTranslation as fcTranslate
|
||||
|
||||
@@ -77,7 +77,7 @@ class TclCommandMillDrills(TclCommandSignaled):
|
||||
|
||||
try:
|
||||
obj = self.app.collection.get_by_name(str(name))
|
||||
except Exception as e:
|
||||
except Exception:
|
||||
obj = None
|
||||
self.raise_tcl_error("Could not retrieve object: %s" % name)
|
||||
|
||||
|
||||
@@ -167,7 +167,8 @@ class TclCommandPanelize(TclCommand):
|
||||
# for col in range(columns):
|
||||
# local_outname = outname + ".tmp." + str(col) + "." + str(row)
|
||||
# if isinstance(obj, ExcellonObject):
|
||||
# self.app.app_obj.new_object("excellon", local_outname, initialize_local_excellon, plot=False,
|
||||
# self.app.app_obj.new_object("excellon", local_outname, initialize_local_excellon,
|
||||
# plot=False,
|
||||
# autoselected=False)
|
||||
# else:
|
||||
# self.app.app_obj.new_object("geometry", local_outname, initialize_local, plot=False,
|
||||
@@ -199,41 +200,36 @@ class TclCommandPanelize(TclCommand):
|
||||
|
||||
def job_init_excellon(obj_fin, app_obj):
|
||||
currenty = 0.0
|
||||
|
||||
obj_fin.tools = obj.tools.copy()
|
||||
obj_fin.drills = []
|
||||
obj_fin.slots = []
|
||||
obj_fin.solid_geometry = []
|
||||
if 'drills' not in obj_fin.tools:
|
||||
obj_fin.tools['drills'] = []
|
||||
if 'slots' not in obj_fin.tools:
|
||||
obj_fin.tools['slots'] = []
|
||||
if 'solid_geometry' not in obj_fin.tools:
|
||||
obj_fin.tools['solid_geometry'] = []
|
||||
|
||||
for option in obj.options:
|
||||
if option != 'name':
|
||||
try:
|
||||
obj_fin.options[option] = obj.options[option]
|
||||
except Exception as e:
|
||||
log.warning("Failed to copy option: %s" % str(option))
|
||||
log.debug("TclCommandPanelize.execute().panelize2() --> %s" % str(e))
|
||||
app_obj.log.warning("Failed to copy option: %s" % str(option))
|
||||
app_obj.log.debug("TclCommandPanelize.execute().panelize2() --> %s" % str(e))
|
||||
|
||||
for row in range(rows):
|
||||
currentx = 0.0
|
||||
for col in range(columns):
|
||||
if obj.drills:
|
||||
for tool_dict in obj.drills:
|
||||
point_offseted = affinity.translate(tool_dict['point'], currentx, currenty)
|
||||
obj_fin.drills.append(
|
||||
{
|
||||
"point": point_offseted,
|
||||
"tool": tool_dict['tool']
|
||||
}
|
||||
)
|
||||
if obj.slots:
|
||||
for tool_dict in obj.slots:
|
||||
start_offseted = affinity.translate(tool_dict['start'], currentx, currenty)
|
||||
stop_offseted = affinity.translate(tool_dict['stop'], currentx, currenty)
|
||||
obj_fin.slots.append(
|
||||
{
|
||||
"start": start_offseted,
|
||||
"stop": stop_offseted,
|
||||
"tool": tool_dict['tool']
|
||||
}
|
||||
if 'drills' in obj.tools:
|
||||
for drill_pt in obj.tools['drills']:
|
||||
point_offseted = affinity.translate(drill_pt, currentx, currenty)
|
||||
obj_fin.tools['drills'].append(point_offseted)
|
||||
if 'slots' in obj.tools:
|
||||
for slot_tuple in obj.tools['slots']:
|
||||
start_offseted = affinity.translate(slot_tuple[0], currentx, currenty)
|
||||
stop_offseted = affinity.translate(slot_tuple[1], currentx, currenty)
|
||||
obj_fin.tools['slots'].append(
|
||||
(start_offseted, stop_offseted)
|
||||
)
|
||||
currentx += lenghtx
|
||||
currenty += lenghty
|
||||
@@ -292,17 +288,15 @@ class TclCommandPanelize(TclCommand):
|
||||
self.app.app_obj.new_object("geometry", outname, job_init_geometry, plot=False, autoselected=True)
|
||||
|
||||
if threaded is True:
|
||||
proc = self.app.proc_container.new("Generating panel ... Please wait.")
|
||||
self.app.proc_container.new("Generating panel ... Please wait.")
|
||||
|
||||
def job_thread(app_obj):
|
||||
try:
|
||||
panelize_2()
|
||||
self.app.inform.emit("[success] Panel created successfully.")
|
||||
app_obj.inform.emit("[success] Panel created successfully.")
|
||||
except Exception as ee:
|
||||
proc.done()
|
||||
log.debug(str(ee))
|
||||
return
|
||||
proc.done()
|
||||
|
||||
self.app.collection.promise(outname)
|
||||
self.app.worker_task.emit({'fcn': job_thread, 'params': [self.app]})
|
||||
|
||||
@@ -67,7 +67,7 @@ class TclCommandPlotObjects(TclCommand):
|
||||
names = [x.strip() for x in args['names'].split(",") if x != '']
|
||||
objs = []
|
||||
for name in names:
|
||||
obj= self.app.collection.get_by_name(name)
|
||||
obj = self.app.collection.get_by_name(name)
|
||||
obj.options["plot"] = True if plot_status is True else False
|
||||
objs.append(obj)
|
||||
|
||||
|
||||
@@ -50,4 +50,4 @@ class TclCommandSaveSys(TclCommandSignaled):
|
||||
:return: None or exception
|
||||
"""
|
||||
|
||||
self.app.preferencesUiManager.save_defaults(args)
|
||||
self.app.preferencesUiManager.save_defaults(args)
|
||||
|
||||
@@ -104,10 +104,9 @@ class TclCommandScale(TclCommand):
|
||||
raise Exception
|
||||
except Exception as e:
|
||||
self.raise_tcl_error('%s\n%s' % (_("Expected -origin <origin> or "
|
||||
"-origin <min_bounds> or "
|
||||
"-origin <center> or "
|
||||
"- origin 3.0,4.2."), str(e))
|
||||
)
|
||||
"-origin <min_bounds> or "
|
||||
"-origin <center> or "
|
||||
"- origin 3.0,4.2."), str(e)))
|
||||
return 'fail'
|
||||
|
||||
if 'factor' in args:
|
||||
|
||||
@@ -52,7 +52,7 @@ class TclCommandSetPath(TclCommand):
|
||||
"By using this command there is no need for usage of the absolute path to the files.",
|
||||
'args': collections.OrderedDict([
|
||||
('path', 'A folder path to where the user is supposed to have the file that he will work with.\n'
|
||||
'WARNING: No spaces allowed. Use quotes around the path if it contains spaces.'),
|
||||
'WARNING: No spaces allowed. Use quotes around the path if it contains spaces.'),
|
||||
]),
|
||||
'examples': ['set_path D:\\Project_storage_path']
|
||||
}
|
||||
|
||||
@@ -87,4 +87,3 @@ class TclCommandSetSys(TclCommand):
|
||||
|
||||
else:
|
||||
self.raise_tcl_error("No such system parameter \"{}\".".format(param))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user