- maintenance_2

This commit is contained in:
Marius Stanciu
2020-06-02 18:29:45 +03:00
committed by Marius
parent 38fa25ed3d
commit f5c84fdc49
255 changed files with 162378 additions and 152106 deletions

View File

@@ -1,6 +1,6 @@
import sys
import re
import FlatCAMApp
import App_Main
import abc
import collections
from PyQt5 import QtCore
@@ -53,7 +53,7 @@ class TclCommand(object):
if self.app is None:
raise TypeError('Expected app to be FlatCAMApp instance.')
if not isinstance(self.app, FlatCAMApp.App):
if not isinstance(self.app, App_Main.App):
raise TypeError('Expected FlatCAMApp, got %s.' % type(app))
self.log = self.app.log

View File

@@ -189,7 +189,7 @@ class TclCommandAlignDrill(TclCommandSignaled):
px = 0.5 * (xmin + xmax)
py = 0.5 * (ymin + ymax)
obj.app.new_object("excellon", outname, alligndrill_init_me, plot=False)
obj.app.app_obj.new_object("excellon", outname, alligndrill_init_me, plot=False)
except Exception as e:
return "Operation failed: %s" % str(e)
@@ -205,7 +205,7 @@ class TclCommandAlignDrill(TclCommandSignaled):
try:
px = dist
py = dist
obj.app.new_object("excellon", outname, alligndrill_init_me, plot=False)
obj.app.app_obj.new_object("excellon", outname, alligndrill_init_me, plot=False)
except Exception as e:
return "Operation failed: %s" % str(e)

View File

@@ -111,4 +111,4 @@ class TclCommandAlignDrillGrid(TclCommandSignaled):
init_obj.create_geometry()
# Create the new object
self.app.new_object("excellon", outname, aligndrillgrid_init_me, plot=False)
self.app.app_obj.new_object("excellon", outname, aligndrillgrid_init_me, plot=False)

View File

@@ -4,7 +4,7 @@ from tclCommands.TclCommand import TclCommand
from shapely.ops import cascaded_union
import gettext
import FlatCAMTranslation as fcTranslate
import AppTranslation as fcTranslate
import builtins
fcTranslate.apply_language('strings')
@@ -100,6 +100,6 @@ class TclCommandBbox(TclCommand):
bounding_box = bounding_box.envelope
geo_obj.solid_geometry = bounding_box
self.app.new_object("geometry", args['outname'], geo_init, plot=False)
self.app.app_obj.new_object("geometry", args['outname'], geo_init, plot=False)
except Exception as e:
return "Operation failed: %s" % str(e)

View File

@@ -3,7 +3,7 @@ import collections
import logging
import gettext
import FlatCAMTranslation as fcTranslate
import AppTranslation as fcTranslate
import builtins
fcTranslate.apply_language('strings')

View File

@@ -37,9 +37,10 @@ class TclCommandCncjob(TclCommandSignaled):
('extracut_length', float),
('dpp', float),
('toolchangez', float),
('toolchangexy', tuple),
('toolchangexy', str),
('startz', float),
('endz', float),
('endxy', str),
('spindlespeed', int),
('dwelltime', float),
('pp', str),
@@ -65,9 +66,12 @@ class TclCommandCncjob(TclCommandSignaled):
('dpp', 'If present then use multidepth cnc cut. Height of one layer for multidepth.'),
('toolchangez', 'Z distance for toolchange (example: 30.0).\n'
'If used in the command then a toolchange event will be included in gcode'),
('toolchangexy', 'X, Y coordonates for toolchange in format (x, y) (example: (2.0, 3.1) ).'),
('toolchangexy', 'The X,Y coordinates at Toolchange event in format (x, y) (example: (30.0, 15.2) or '
'without parenthesis like: 0.3,1.0). WARNING: no spaces allowed in the value.'),
('startz', 'Height before the first move.'),
('endz', 'Height where the last move will park.'),
('endxy', 'The X,Y coordinates at job end in format (x, y) (example: (2.0, 1.2) or without parenthesis'
'like: 0.3,1.0). WARNING: no spaces allowed in the value.'),
('spindlespeed', 'Speed of the spindle in rpm (example: 4000).'),
('dwelltime', 'Time to pause to allow the spindle to reach the full speed.\n'
'If it is not used in command then it will not be included'),
@@ -124,16 +128,18 @@ class TclCommandCncjob(TclCommandSignaled):
else:
return
args["dia"] = args["dia"] if "dia" in args and args["dia"] else obj.options["cnctooldia"]
args["dia"] = args["dia"] if "dia" in args and args["dia"] else self.app.defaults["geometry_cnctooldia"]
args["z_cut"] = args["z_cut"] if "z_cut" in args and args["z_cut"] else obj.options["cutz"]
args["z_move"] = args["z_move"] if "z_move" in args and args["z_move"] else obj.options["travelz"]
args["z_cut"] = args["z_cut"] if "z_cut" in args and args["z_cut"] else self.app.defaults["geometry_cutz"]
args["z_move"] = args["z_move"] if "z_move" in args and args["z_move"] else \
self.app.defaults["geometry_travelz"]
args["feedrate"] = args["feedrate"] if "feedrate" in args and args["feedrate"] else obj.options["feedrate"]
args["feedrate"] = args["feedrate"] if "feedrate" in args and args["feedrate"] else \
self.app.defaults["geometry_feedrate"]
args["feedrate_z"] = args["feedrate_z"] if "feedrate_z" in args and args["feedrate_z"] else \
obj.options["feedrate_z"]
self.app.defaults["geometry_feedrate_z"]
args["feedrate_rapid"] = args["feedrate_rapid"] if "feedrate_rapid" in args and args["feedrate_rapid"] else \
obj.options["feedrate_rapid"]
self.app.defaults["geometry_feedrate_rapid"]
if "extracut_length" in args:
args["extracut"] = True
@@ -142,20 +148,33 @@ class TclCommandCncjob(TclCommandSignaled):
else:
args["extracut_length"] = float(args["extracut_length"])
else:
args["extracut"] = False
args["extracut"] = self.app.defaults["geometry_extracut"]
args["extracut_length"] = self.app.defaults["geometry_extracut_length"]
if "dpp" in args:
args["multidepth"] = True
if args["dpp"] is None:
args["dpp"] = obj.options["dpp"]
args["dpp"] =self.app.defaults["geometry_depthperpass"]
else:
args["dpp"] = float(args["dpp"])
else:
args["multidepth"] = False
args["multidepth"] = self.app.defaults["geometry_multidepth"]
args["dpp"] = self.app.defaults["geometry_depthperpass"]
args["startz"] = args["startz"] if "startz" in args and args["startz"] else \
self.app.defaults["geometry_startz"]
args["endz"] = args["endz"] if "endz" in args and args["endz"] else obj.options["endz"]
args["endz"] = args["endz"] if "endz" in args and args["endz"] else self.app.defaults["geometry_endz"]
if "endxy" in args and args["endxy"]:
args["endxy"] = args["endxy"]
else:
if self.app.defaults["geometry_endxy"]:
args["endxy"] = self.app.defaults["geometry_endxy"]
else:
args["endxy"] = '0, 0'
if len(eval(args["endxy"])) != 2:
self.raise_tcl_error("The entered value for 'endxy' needs to have the format x,y or "
"in format (x, y) - no spaces allowed. But always two comma separated values.")
args["spindlespeed"] = args["spindlespeed"] if "spindlespeed" in args and args["spindlespeed"] != 0 else None
@@ -166,23 +185,31 @@ class TclCommandCncjob(TclCommandSignaled):
else:
args["dwelltime"] = float(args['dwelltime'])
else:
args["dwell"] = False
args["dwelltime"] = 0.0
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 obj.options["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
if args["toolchangez"] is not None:
args["toolchangez"] = args["toolchangez"]
else:
args["toolchangez"] = obj.options["toolchangez"]
args["toolchangez"] = self.app.defaults["geometry_toolchangez"]
else:
args["toolchange"] = False
args["toolchangez"] = 0.0
args["toolchange"] = self.app.defaults["geometry_toolchange"]
args["toolchangez"] = self.app.defaults["geometry_toolchangez"]
args["toolchangexy"] = args["toolchangexy"] if "toolchangexy" in args and args["toolchangexy"] else \
self.app.defaults["geometry_toolchangexy"]
if "toolchangexy" in args and args["toolchangexy"]:
args["toolchangexy"] = args["toolchangexy"]
else:
if self.app.defaults["geometry_toolchangexy"]:
args["toolchangexy"] = self.app.defaults["geometry_toolchangexy"]
else:
args["toolchangexy"] = '0, 0'
if len(eval(args["toolchangexy"])) != 2:
self.raise_tcl_error("The entered value for 'toolchangexy' needs to have the format x,y or "
"in format (x, y) - no spaces allowed. But always two comma separated values.")
del args['name']
@@ -191,7 +218,7 @@ class TclCommandCncjob(TclCommandSignaled):
continue
else:
if args[arg] is None:
print(arg, args[arg])
print("None parameters: %s is None" % arg)
if muted is False:
self.raise_tcl_error('One of the command parameters that have to be not None, is None.\n'
'The parameter that is None is in the default values found in the list \n'
@@ -201,7 +228,7 @@ class TclCommandCncjob(TclCommandSignaled):
# HACK !!! Should be solved elsewhere!!!
# default option for multidepth is False
obj.options['multidepth'] = False
# obj.options['multidepth'] = False
if not obj.multigeo:
obj.generatecncjob(use_thread=False, plot=False, **args)
@@ -230,6 +257,7 @@ class TclCommandCncjob(TclCommandSignaled):
local_tools_dict[tool_uid]['data']['toolchangexy'] = args["toolchangexy"]
local_tools_dict[tool_uid]['data']['startz'] = args["startz"]
local_tools_dict[tool_uid]['data']['endz'] = args["endz"]
local_tools_dict[tool_uid]['data']['endxy'] = args["endxy"]
local_tools_dict[tool_uid]['data']['spindlespeed'] = args["spindlespeed"]
local_tools_dict[tool_uid]['data']['dwell'] = args["dwell"]
local_tools_dict[tool_uid]['data']['dwelltime'] = args["dwelltime"]

View File

@@ -4,7 +4,7 @@ import collections
import logging
import gettext
import FlatCAMTranslation as fcTranslate
import AppTranslation as fcTranslate
import builtins
fcTranslate.apply_language('strings')
@@ -54,8 +54,8 @@ class TclCommandCopperClear(TclCommand):
'main': "Clear excess copper in polygons. Basically it's a negative Paint.",
'args': collections.OrderedDict([
('name', 'Name of the source Geometry object. String.'),
('tooldia', 'Diameter of the tool to be used. Can be a comma separated list of diameters. No space is '
'allowed between tool diameters. E.g: correct: 0.5,1 / incorrect: 0.5, 1'),
('tooldia', 'Diameter of the tool to be used. Can be a comma separated list of diameters.\n'
'WARNING: No space is allowed between tool diameters. E.g: correct: 0.5,1 / incorrect: 0.5, 1'),
('overlap', 'Percentage of tool diameter to overlap current pass over previous pass. Float [0, 99.9999]\n'
'E.g: for a 25% from tool diameter overlap use -overlap 25'),
('margin', 'Bounding box margin. Float number.'),
@@ -72,7 +72,7 @@ class TclCommandCopperClear(TclCommand):
('all', 'If used will copper clear the whole object. Either "-all" or "-box <value>" has to be used.'),
('box', 'Name of the object to be used as reference. Either "-all" or "-box <value>" has to be used. '
'String.'),
('outname', 'Name of the resulting Geometry object. String.'),
('outname', 'Name of the resulting Geometry object. String. No spaces.'),
]),
'examples': ["ncc obj_name -tooldia 0.3,1 -overlap 10 -margin 1.0 -method 'lines' -all"]
}

View File

@@ -137,7 +137,7 @@ class TclCommandCutout(TclCommand):
geo_obj.solid_geometry = cascaded_union([LineString(segment) for segment in cuts])
try:
self.app.new_object("geometry", outname, geo_init_me, plot=False)
self.app.app_obj.new_object("geometry", outname, geo_init_me, plot=False)
self.app.inform.emit("[success] Rectangular-form Cutout operation finished.")
except Exception as e:
return "Operation failed: %s" % str(e)

View File

@@ -4,7 +4,7 @@ import collections
import math
import gettext
import FlatCAMTranslation as fcTranslate
import AppTranslation as fcTranslate
import builtins
fcTranslate.apply_language('strings')
@@ -37,10 +37,10 @@ class TclCommandDrillcncjob(TclCommandSignaled):
('feedrate_rapid', float),
('spindlespeed', int),
('toolchangez', float),
('toolchangexy', tuple),
('toolchangexy', str),
('startz', float),
('endz', float),
('endxy', tuple),
('endxy', str),
('dwelltime', float),
('pp', str),
('opt_type', str),
@@ -59,7 +59,7 @@ class TclCommandDrillcncjob(TclCommandSignaled):
('name', 'Name of the source object.'),
('drilled_dias',
'Comma separated tool diameters of the drills to be drilled (example: 0.6,1.0 or 3.125). '
'No space allowed'),
'WARNING: No space allowed'),
('drillz', 'Drill depth into material (example: -2.0). Negative value.'),
('dpp', 'Progressive drilling into material with a specified step (example: 0.7). Positive value.'),
('travelz', 'Travel distance above material (example: 2.0).'),
@@ -68,10 +68,12 @@ class TclCommandDrillcncjob(TclCommandSignaled):
('spindlespeed', 'Speed of the spindle in rpm (example: 4000).'),
('toolchangez', 'Z distance for toolchange (example: 30.0).\n'
'If used in the command then a toolchange event will be included in gcode'),
('toolchangexy', 'X, Y coordonates for toolchange in format (x, y) (example: (2.0, 3.1) ).'),
('toolchangexy', 'The X,Y coordinates at Toolchange event in format (x, y) (example: (30.0, 15.2) or '
'without parenthesis like: 0.3,1.0). WARNING: no spaces allowed in the value.'),
('startz', 'The Z coordinate at job start (example: 30.0).'),
('endz', 'The Z coordinate at job end (example: 30.0).'),
('endxy', 'The X,Y coordinates at job end in format (x, y) (example: (30.0, 15.2)).'),
('endxy', 'The X,Y coordinates at job end in format (x, y) (example: (2.0, 1.2) or without parenthesis'
'like: 0.3,1.0). WARNING: no spaces allowed in the value.'),
('dwelltime', 'Time to pause to allow the spindle to reach the full speed.\n'
'If it is not used in command then it will not be included'),
('pp', 'This is the Excellon preprocessor name: case_sensitive, no_quotes'),
@@ -227,17 +229,34 @@ class TclCommandDrillcncjob(TclCommandSignaled):
else:
toolchangez = obj.options["toolchangez"]
else:
toolchange = False
toolchangez = 0.0
toolchange = self.app.defaults["excellon_toolchange"]
toolchangez = float(self.app.defaults["excellon_toolchangez"])
xy_toolchange = args["toolchangexy"] if "toolchangexy" in args and args["toolchangexy"] else \
obj.options["toolchangexy"]
xy_toolchange = ','.join([xy_toolchange[0], xy_toolchange[2]])
if "toolchangexy" in args and args["toolchangexy"]:
xy_toolchange = args["toolchangexy"]
else:
if self.app.defaults["excellon_toolchangexy"]:
xy_toolchange = self.app.defaults["excellon_toolchangexy"]
else:
xy_toolchange = '0, 0'
if len(eval(xy_toolchange)) != 2:
self.raise_tcl_error("The entered value for 'toolchangexy' needs to have the format x,y or "
"in format (x, y) - no spaces allowed. But always two comma separated values.")
endz = args["endz"] if "endz" in args and args["endz"] is not None else self.app.defaults["excellon_endz"]
if "endxy" in args and args["endxy"]:
xy_end = args["endxy"]
else:
if self.app.defaults["excellon_endxy"]:
xy_end = self.app.defaults["excellon_endxy"]
else:
xy_end = '0, 0'
if len(eval(xy_end)) != 2:
self.raise_tcl_error("The entered value for 'xy_end' needs to have the format x,y or "
"in format (x, y) - no spaces allowed. But always two comma separated values.")
endz = args["endz"] if "endz" in args and args["endz"] is not None else obj.options["endz"]
xy_end = args["endxy"] if "endxy" in args and args["endxy"] else '0,0'
xy_end = ','.join([xy_end[0], xy_end[2]])
print(xy_end)
opt_type = args["opt_type"] if "opt_type" in args and args["opt_type"] else 'B'
# ##########################################################################################
@@ -248,7 +267,7 @@ class TclCommandDrillcncjob(TclCommandSignaled):
job_obj.options['Tools_in_use'] = used_tools_info
job_obj.options['type'] = 'Excellon'
pp_excellon_name = args["pp"] if "pp" in args and args["pp"] else obj.options["ppname_e"]
pp_excellon_name = args["pp"] if "pp" in args and args["pp"] else self.app.defaults["excellon_ppname_e"]
job_obj.pp_excellon_name = pp_excellon_name
job_obj.options['ppname_e'] = pp_excellon_name
@@ -259,16 +278,19 @@ class TclCommandDrillcncjob(TclCommandSignaled):
else:
job_obj.z_depthpercut = float(obj.options["dpp"])
else:
job_obj.multidepth = False
job_obj.z_depthpercut = 0.0
job_obj.multidepth = self.app.defaults["excellon_multidepth"]
job_obj.z_depthpercut = self.app.defaults["excellon_depthperpass"]
job_obj.z_move = float(args["travelz"]) if "travelz" in args and args["travelz"] else \
self.app.defaults["excellon_travelz"]
job_obj.z_move = float(args["travelz"]) if "travelz" in args and args["travelz"] else obj.options["travelz"]
job_obj.feedrate = float(args["feedrate_z"]) if "feedrate_z" in args and args["feedrate_z"] else \
obj.options["feedrate_z"]
self.app.defaults["excellon_feedrate_z"]
job_obj.z_feedrate = float(args["feedrate_z"]) if "feedrate_z" in args and args["feedrate_z"] else \
obj.options["feedrate_z"]
self.app.defaults["excellon_feedrate_z"]
job_obj.feedrate_rapid = float(args["feedrate_rapid"]) \
if "feedrate_rapid" in args and args["feedrate_rapid"] else obj.options["feedrate_rapid"]
if "feedrate_rapid" in args and args["feedrate_rapid"] else self.app.defaults["excellon_feedrate_rapid"]
job_obj.spindlespeed = float(args["spindlespeed"]) if "spindlespeed" in args else None
job_obj.spindledir = self.app.defaults['excellon_spindledir']
@@ -277,10 +299,10 @@ class TclCommandDrillcncjob(TclCommandSignaled):
if args['dwelltime'] is not None:
job_obj.dwelltime = float(args['dwelltime'])
else:
job_obj.dwelltime = float(obj.options["dwelltime"])
job_obj.dwelltime = float(self.app.defaults["excellon_dwelltime"])
else:
job_obj.dwell = False
job_obj.dwelltime = 0.0
job_obj.dwell = self.app.defaults["excellon_dwell"]
job_obj.dwelltime = self.app.defaults["excellon_dwelltime"]
job_obj.toolchange_xy_type = "excellon"
job_obj.coords_decimals = int(self.app.defaults["cncjob_coords_decimals"])
@@ -295,7 +317,15 @@ class TclCommandDrillcncjob(TclCommandSignaled):
job_obj.toolchange = toolchange
job_obj.xy_toolchange = xy_toolchange
job_obj.z_toolchange = float(toolchangez)
job_obj.startz = float(args["startz"]) if "endz" in args and args["endz"] is not None else (0, 0)
if "startz" in args and args["startz"] is not None:
job_obj.startz = float(args["startz"])
else:
if self.app.defaults["excellon_startz"]:
job_obj.startz = self.app.defaults["excellon_startz"]
else:
job_obj.startz = (0, 0)
job_obj.endz = float(endz)
job_obj.xy_end = xy_end
job_obj.excellon_optimization_type = opt_type
@@ -313,4 +343,4 @@ class TclCommandDrillcncjob(TclCommandSignaled):
job_obj.gcode_parse()
job_obj.create_geometry()
self.app.new_object("cncjob", args['outname'], job_init, plot=False)
self.app.app_obj.new_object("cncjob", args['outname'], job_init, plot=False)

View File

@@ -66,4 +66,4 @@ class TclCommandExteriors(TclCommandSignaled):
geo_obj.solid_geometry = obj_exteriors
obj_exteriors = obj.get_exteriors()
self.app.new_object('geometry', outname, geo_init, plot=False)
self.app.app_obj.new_object('geometry', outname, geo_init, plot=False)

View File

@@ -7,7 +7,7 @@ from shapely.ops import cascaded_union
from shapely.geometry import Polygon, LineString, LinearRing
import gettext
import FlatCAMTranslation as fcTranslate
import AppTranslation as fcTranslate
import builtins
log = logging.getLogger('base')
@@ -300,11 +300,8 @@ class TclCommandGeoCutout(TclCommandSignaled):
app_obj.inform.emit("[success] %s" % _("Any-form Cutout operation finished."))
self.app.new_object('geometry', outname, geo_init, plot=False)
self.app.app_obj.new_object('geometry', outname, geo_init, plot=False)
# cutout_obj.plot()
# self.app.inform.emit("[success] Any-form Cutout operation finished.")
# self.app.plots_updated.emit()
elif cutout_obj.kind == 'gerber':
def geo_init(geo_obj, app_obj):
@@ -358,7 +355,7 @@ class TclCommandGeoCutout(TclCommandSignaled):
geo_obj.options['ymax'] = cutout_obj.options['ymax']
app_obj.inform.emit("[success] %s" % _("Any-form Cutout operation finished."))
self.app.new_object('geometry', outname, geo_init, plot=False)
self.app.app_obj.new_object('geometry', outname, geo_init, plot=False)
cutout_obj = self.app.collection.get_by_name(outname)
else:

View File

@@ -5,7 +5,7 @@ import collections
class TclCommandGetNames(TclCommand):
"""
Tcl shell command to set an object as active in the GUI.
Tcl shell command to set an object as active in the AppGUI.
example:

View File

@@ -11,7 +11,7 @@ import collections
import os
import logging
import gettext
import FlatCAMTranslation as fcTranslate
import AppTranslation as fcTranslate
import builtins
fcTranslate.apply_language('strings')

View File

@@ -11,7 +11,7 @@ from tclCommands.TclCommand import TclCommand
import collections
import gettext
import FlatCAMTranslation as fcTranslate
import AppTranslation as fcTranslate
import builtins
fcTranslate.apply_language('strings')

View File

@@ -76,7 +76,7 @@ class TclCommandImportSvg(TclCommandSignaled):
with self.app.proc_container.new("Import SVG"):
# Object creation
self.app.new_object(obj_type, outname, obj_init, plot=False)
self.app.app_obj.new_object(obj_type, outname, obj_init, plot=False)
# Register recent file
self.app.file_opened.emit("svg", filename)

View File

@@ -67,4 +67,4 @@ class TclCommandInteriors(TclCommandSignaled):
geo_obj.solid_geometry = obj_interiors
obj_interiors = obj.get_interiors()
self.app.new_object('geometry', outname, geo_init)
self.app.app_obj.new_object('geometry', outname, geo_init)

View File

@@ -89,7 +89,7 @@ class TclCommandIsolate(TclCommandSignaled):
par = args['combine']
args['combine'] = bool(eval(par))
else:
args['combine'] = bool(eval(self.app.defaults["gerber_combine_passes"]))
args['combine'] = bool(eval(self.app.defaults["tools_iso_combine_passes"]))
obj = self.app.collection.get_by_name(name)
if obj is None:

View File

@@ -1,5 +1,5 @@
from tclCommands.TclCommand import TclCommand
from flatcamObjects.FlatCAMExcellon import ExcellonObject
from AppObjects.FlatCAMExcellon import ExcellonObject
import collections
@@ -65,6 +65,6 @@ class TclCommandJoinExcellon(TclCommand):
ExcellonObject.merge(objs, obj_, decimals=self.app.decimals)
if objs and len(objs) >= 2:
self.app.new_object("excellon", outname, initialize, plot=False)
self.app.app_obj.new_object("excellon", outname, initialize, plot=False)
else:
return "No Excellon objects to be joined or less than two Excellon objects specified for merging."

View File

@@ -1,5 +1,5 @@
from tclCommands.TclCommand import TclCommand
from flatcamObjects.FlatCAMGeometry import GeometryObject
from AppObjects.FlatCAMGeometry import GeometryObject
import collections
@@ -65,6 +65,6 @@ class TclCommandJoinGeometry(TclCommand):
GeometryObject.merge(objs, obj_)
if objs and len(objs) >= 2:
self.app.new_object("geometry", outname, initialize, plot=False)
self.app.app_obj.new_object("geometry", outname, initialize, plot=False)
else:
return "No Geometry objects to be joined or less than two Geometry objects specified for merging."

View File

@@ -58,4 +58,4 @@ class TclCommandNewExcellon(TclCommandSignaled):
name = args['name']
else:
name = 'new_exc'
self.app.new_object('excellon', name, lambda x, y: None, plot=False)
self.app.app_obj.new_object('excellon', name, lambda x, y: None, plot=False)

View File

@@ -52,4 +52,4 @@ class TclCommandNewGeometry(TclCommandSignaled):
else:
name = 'new_geo'
self.app.new_object('geometry', str(name), lambda x, y: None, plot=False)
self.app.app_obj.new_object('geometry', str(name), lambda x, y: None, plot=False)

View File

@@ -75,4 +75,4 @@ class TclCommandNewGerber(TclCommandSignaled):
except KeyError:
pass
self.app.new_object('gerber', name, initialize, plot=False)
self.app.app_obj.new_object('gerber', name, initialize, plot=False)

View File

@@ -5,7 +5,7 @@ from shapely.ops import cascaded_union
import collections
import gettext
import FlatCAMTranslation as fcTranslate
import AppTranslation as fcTranslate
import builtins
fcTranslate.apply_language('strings')
@@ -100,7 +100,7 @@ class TclCommandNregions(TclCommand):
non_copper = bounding_box.difference(geo)
geo_obj.solid_geometry = non_copper
self.app.new_object("geometry", args['outname'], geo_init, plot=False)
self.app.app_obj.new_object("geometry", args['outname'], geo_init, plot=False)
except Exception as e:
return "Operation failed: %s" % str(e)

View File

@@ -77,10 +77,10 @@ class TclCommandOpenDXF(TclCommandSignaled):
with self.app.proc_container.new("Open DXF"):
# Object creation
ret_val = self.app.new_object(obj_type, outname, obj_init, plot=False)
ret_val = self.app.app_obj.new_object(obj_type, outname, obj_init, plot=False)
if ret_val == 'fail':
filename = self.app.defaults['global_tcl_path'] + '/' + outname
ret_val = self.app.new_object(obj_type, outname, obj_init, plot=False)
ret_val = self.app.app_obj.new_object(obj_type, outname, obj_init, plot=False)
self.app.shell.append_output(
"No path provided or path is wrong. Using the default Path... \n")

View File

@@ -77,10 +77,10 @@ class TclCommandOpenSVG(TclCommandSignaled):
with self.app.proc_container.new("Import SVG"):
# Object creation
ret_val = self.app.new_object(obj_type, outname, obj_init, plot=False)
ret_val = self.app.app_obj.new_object(obj_type, outname, obj_init, plot=False)
if ret_val == 'fail':
filename = self.app.defaults['global_tcl_path'] + '/' + outname
ret_val = self.app.new_object(obj_type, outname, obj_init, plot=False)
ret_val = self.app.app_obj.new_object(obj_type, outname, obj_init, plot=False)
self.app.shell.append_output(
"No path provided or path is wrong. Using the default Path... \n")
if ret_val == 'fail':

View File

@@ -4,7 +4,7 @@ import collections
import logging
import gettext
import FlatCAMTranslation as fcTranslate
import AppTranslation as fcTranslate
import builtins
fcTranslate.apply_language('strings')
@@ -43,8 +43,6 @@ class TclCommandPaint(TclCommand):
('single', str),
('ref', str),
('box', str),
('x', float),
('y', float),
('outname', str),
])
@@ -53,30 +51,32 @@ class TclCommandPaint(TclCommand):
# structured help for current command, args needs to be ordered
help = {
'main': "Paint polygons in the specified object by covering them with toolpaths.",
'main': "Paint polygons in the specified object by covering them with toolpaths.\n"
"Can use only one of the parameters: 'all', 'box', 'single'.",
'args': collections.OrderedDict([
('name', 'Name of the source Geometry object. String.'),
('tooldia', 'Diameter of the tool to be used. Can be a comma separated list of diameters. No space is '
'allowed between tool diameters. E.g: correct: 0.5,1 / incorrect: 0.5, 1'),
('tooldia', 'Diameter of the tools to be used. Can be a comma separated list of diameters.\n'
'WARNING: No space is allowed between tool diameters. E.g: correct: 0.5,1 / incorrect: 0.5, 1'),
('overlap', 'Percentage of tool diameter to overlap current pass over previous pass. Float [0, 99.9999]\n'
'E.g: for a 25% from tool diameter overlap use -overlap 25'),
('margin', 'Bounding box margin. Float number.'),
('order', 'Can have the values: "no", "fwd" and "rev". String.'
'It is useful when there are multiple tools in tooldia parameter.'
'"no" -> the order used is the one provided.'
'"fwd" -> tools are ordered from smallest to biggest.'
('order', 'Can have the values: "no", "fwd" and "rev". String.\n'
'It is useful when there are multiple tools in tooldia parameter.\n'
'"no" -> the order used is the one provided.\n'
'"fwd" -> tools are ordered from smallest to biggest.\n'
'"rev" -> tools are ordered from biggest to smallest.'),
('method', 'Algorithm for painting. Can be: "standard", "seed", "lines", "laser_lines", "combo".'),
('connect', 'Draw lines to minimize tool lifts. True (1) or False (0)'),
('contour', 'Cut around the perimeter of the painting. True (1) or False (0)'),
('all', 'If used, paint all polygons in the object.'),
('box', 'name of the object to be used as paint reference. String.'),
('single', 'Paint a single polygon specified by "x" and "y" parameters. True (1) or False (0)'),
('x', 'X value of coordinate for the selection of a single polygon. Float number.'),
('y', 'Y value of coordinate for the selection of a single polygon. Float number.'),
('outname', 'Name of the resulting Geometry object. String.'),
('single', 'Value is in format x,y or (x,y). Example: 2.0,1.1\n'
'If used will paint a single polygon specified by "x" and "y" values.\n'
'WARNING: No spaces allowed in the value. Use dot decimals separator.'),
('outname', 'Name of the resulting Geometry object. String. No spaces.'),
]),
'examples': ["paint obj_name -tooldia 0.3 -margin 0.1 -method 'seed' -all"]
'examples': ["paint obj_name -tooldia 0.3 -margin 0.1 -method 'seed' -all",
"paint obj_name -tooldia 0.3 -margin 0.1 -method 'seed' -single 3.3,2.0"]
}
def execute(self, args, unnamed_args):
@@ -159,7 +159,7 @@ class TclCommandPaint(TclCommand):
# used only to have correct information's in the obj.tools[tool]['data'] dict
if "all" in args:
select = _("All Polygons")
select = _("All")
elif "single" in args:
select = _("Polygon Selection")
else:
@@ -245,11 +245,17 @@ class TclCommandPaint(TclCommand):
# Paint single polygon in the painted object
if 'single' in args:
if 'x' not in args and 'y' not in args:
self.raise_tcl_error('%s' % _("Expected -x <value> and -y <value>."))
if not args['single'] or args['single'] == '':
self.raise_tcl_error('%s Got: %s' %
(_("Expected a tuple value like -single 3.2,0.1."), str(args['single'])))
else:
x = args['x']
y = args['y']
coords_xy = [float(eval(a)) for a in args['single'].split(",") if a != '']
if coords_xy and len(coords_xy) != 2:
self.raise_tcl_error('%s Got: %s' %
(_("Expected a tuple value like -single 3.2,0.1."), str(coords_xy)))
x = coords_xy[0]
y = coords_xy[1]
self.app.paint_tool.paint_poly(obj=obj,
inside_pt=[x, y],

View File

@@ -167,19 +167,19 @@ class TclCommandPanelize(TclCommand):
# for col in range(columns):
# local_outname = outname + ".tmp." + str(col) + "." + str(row)
# if isinstance(obj, ExcellonObject):
# self.app.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.new_object("geometry", local_outname, initialize_local, plot=False,
# self.app.app_obj.new_object("geometry", local_outname, initialize_local, plot=False,
# autoselected=False)
#
# currentx += lenghtx
# currenty += lenghty
#
# if isinstance(obj, ExcellonObject):
# self.app.new_object("excellon", outname, initialize_excellon)
# self.app.app_obj.new_object("excellon", outname, initialize_excellon)
# else:
# self.app.new_object("geometry", outname, initialize_geometry)
# self.app.app_obj.new_object("geometry", outname, initialize_geometry)
#
# # deselect all to avoid delete selected object when run delete from shell
# self.app.collection.set_all_inactive()
@@ -287,9 +287,9 @@ class TclCommandPanelize(TclCommand):
currenty += lenghty
if obj.kind == 'excellon':
self.app.new_object("excellon", outname, job_init_excellon, plot=False, autoselected=True)
self.app.app_obj.new_object("excellon", outname, job_init_excellon, plot=False, autoselected=True)
else:
self.app.new_object("geometry", outname, job_init_geometry, plot=False, autoselected=True)
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.")

View File

@@ -14,7 +14,7 @@ class TclCommandPlotAll(TclCommandSignaled):
# List of all command aliases, to be able use old names for backward compatibility (add_poly, add_polygon)
aliases = ['plot_all']
description = '%s %s' % ("--", "Plots all objects on GUI.")
description = '%s %s' % ("--", "Plots all objects on AppGUI.")
# Dictionary of types from Tcl command, needs to be ordered
arg_names = collections.OrderedDict([
@@ -32,7 +32,7 @@ class TclCommandPlotAll(TclCommandSignaled):
# structured help for current command, args needs to be ordered
help = {
'main': "Plots all objects on GUI.",
'main': "Plots all objects on AppGUI.",
'args': collections.OrderedDict([
('plot_status', 'If to display or not the objects: True (1) or False (0).'),
('use_thread', 'If to use multithreading: True (1) or False (0).')

View File

@@ -21,7 +21,7 @@ class TclCommandPlotObjects(TclCommand):
# List of all command aliases, to be able use old names for backward compatibility (add_poly, add_polygon)
aliases = ['plot_objects']
description = '%s %s' % ("--", "Plot a specified list of objects in GUI.")
description = '%s %s' % ("--", "Plot a specified list of objects in AppGUI.")
# Dictionary of types from Tcl command, needs to be ordered
arg_names = collections.OrderedDict([
@@ -38,7 +38,7 @@ class TclCommandPlotObjects(TclCommand):
# structured help for current command, args needs to be ordered
help = {
'main': "Plot a specified list of objects in GUI.",
'main': "Plot a specified list of objects in AppGUI.",
'args': collections.OrderedDict([
('names', "A list of object names to be plotted separated by comma. Required.\n"
"WARNING: no spaces are allowed. If unsure enclose the entire list with quotes."),

View File

@@ -4,7 +4,7 @@ import collections
import logging
import gettext
import FlatCAMTranslation as fcTranslate
import AppTranslation as fcTranslate
import builtins
fcTranslate.apply_language('strings')

View File

@@ -5,7 +5,7 @@ import collections
class TclCommandSetActive(TclCommand):
"""
Tcl shell command to set an object as active in the GUI.
Tcl shell command to set an object as active in the AppGUI.
example:

View File

@@ -13,7 +13,7 @@ from camlib import get_bounds
import logging
import gettext
import FlatCAMTranslation as fcTranslate
import AppTranslation as fcTranslate
import builtins
fcTranslate.apply_language('strings')
@@ -98,6 +98,6 @@ class TclCommandSetOrigin(TclCommand):
loc = [0, 0]
self.app.on_set_zero_click(event=None, location=loc, noplot=True, use_thread=False)
self.app.inform.emit('[success] Tcl %s: %s' %
(_('Origin set by offsetting all loaded objects with '),
'{0:.4f}, {0:.4f}'.format(loc[0], loc[1])))
msg = '[success] Tcl %s: %s' % (_('Origin set by offsetting all loaded objects with '),
'{0:.4f}, {0:.4f}'.format(loc[0], loc[1]))
self.app.shell_message(msg, success=True, show=False)

View File

@@ -11,7 +11,7 @@ import collections
import os
import logging
import gettext
import FlatCAMTranslation as fcTranslate
import AppTranslation as fcTranslate
import builtins
fcTranslate.apply_language('strings')
@@ -75,19 +75,22 @@ class TclCommandSetPath(TclCommand):
if path_isdir is False:
path_isfile = os.path.isfile(path)
if path_isfile:
self.app.inform.emit('[ERROR] %s: %s, %s' % (
msg = '[ERROR] %s: %s, %s' % (
"The provided path",
str(path),
"is a path to file and not a directory as expected."))
"is a path to file and not a directory as expected.")
self.app.shell_message(msg, success=True, show=False)
return "Failed. The Tcl command set_path was used but it was not a directory."
else:
self.app.inform.emit('[ERROR] %s: %s, %s' % (
msg = '[ERROR] %s: %s, %s' % (
"The provided path",
str(path),
"do not exist. Check for typos."))
"do not exist. Check for typos.")
self.app.shell_message(msg, success=True, show=False)
return "Failed. The Tcl command set_path was used but it does not exist."
cd_command = 'cd %s' % path
self.app.shell.exec_command(cd_command, no_echo=False)
self.app.defaults["global_tcl_path"] = str(path)
self.app.inform.emit('[success] %s: %s' % ("Relative path set to", str(path)))
msg = '[success] %s: %s' % ("Relative path set to", str(path))
self.app.shell_message(msg, success=True, show=False)

View File

@@ -3,7 +3,7 @@ from tclCommands.TclCommand import TclCommandSignaled
import collections
import gettext
import FlatCAMTranslation as fcTranslate
import AppTranslation as fcTranslate
import builtins
fcTranslate.apply_language('strings')

View File

@@ -80,15 +80,15 @@ class TclCommandWriteGCode(TclCommandSignaled):
# This is not needed any more? All targets should be present.
# If there are promised objects, wait until all promises have been fulfilled.
# if self.collection.has_promises():
# def write_gcode_on_object(new_object):
# def write_gcode_on_object(app_obj.new_object):
# self.log.debug("write_gcode_on_object(): Disconnecting %s" % write_gcode_on_object)
# self.new_object_available.disconnect(write_gcode_on_object)
# self.app_obj.new_object_available.disconnect(write_gcode_on_object)
# write_gcode(obj_name, filename, preamble, postamble)
#
# # Try again when a new object becomes available.
# self.log.debug("write_gcode(): Collection has promises. Queued for %s." % obj_name)
# self.log.debug("write_gcode(): Queued function: %s" % write_gcode_on_object)
# self.new_object_available.connect(write_gcode_on_object)
# self.app_obj.new_object_available.connect(write_gcode_on_object)
#
# return