Merged in Beta (pull request #329)
Several bugfixes in the beta branch found while using scripts Approved-by: Marius Stanciu
This commit is contained in:
commit
a8a2f6b0e9
|
@ -2278,6 +2278,8 @@ class GeometryObject(FlatCAMObj, Geometry):
|
||||||
dia_cnc_dict.update({
|
dia_cnc_dict.update({
|
||||||
'tooldia': tooldia_val
|
'tooldia': tooldia_val
|
||||||
})
|
})
|
||||||
|
if "optimization_type" not in tools_dict[tooluid_key]['data']:
|
||||||
|
tools_dict[tooluid_key]['data']["optimization_type"] = self.app.defaults["geometry_optimization_type"]
|
||||||
|
|
||||||
# find the tool_dia associated with the tooluid_key
|
# find the tool_dia associated with the tooluid_key
|
||||||
# search in the self.tools for the sel_tool_dia and when found see what tooluid has
|
# search in the self.tools for the sel_tool_dia and when found see what tooluid has
|
||||||
|
|
|
@ -2869,7 +2869,7 @@ class NonCopperClear(AppTool, Gerber):
|
||||||
bounding_box = unary_union(geo_buff_list)
|
bounding_box = unary_union(geo_buff_list)
|
||||||
elif ncc_sel_obj.kind == 'gerber':
|
elif ncc_sel_obj.kind == 'gerber':
|
||||||
geo_n = unary_union(geo_n).convex_hull
|
geo_n = unary_union(geo_n).convex_hull
|
||||||
bounding_box = unary_union(self.ncc_obj.solid_geometry).convex_hull.intersection(geo_n)
|
bounding_box = unary_union(ncc_sel_obj.solid_geometry).convex_hull.intersection(geo_n)
|
||||||
bounding_box = bounding_box.buffer(distance=ncc_margin, join_style=base.JOIN_STYLE.mitre)
|
bounding_box = bounding_box.buffer(distance=ncc_margin, join_style=base.JOIN_STYLE.mitre)
|
||||||
else:
|
else:
|
||||||
self.app.inform.emit('[ERROR_NOTCL] %s' % _("The reference object type is not supported."))
|
self.app.inform.emit('[ERROR_NOTCL] %s' % _("The reference object type is not supported."))
|
||||||
|
@ -3315,7 +3315,7 @@ class NonCopperClear(AppTool, Gerber):
|
||||||
rest_geo = []
|
rest_geo = []
|
||||||
current_uid = 1
|
current_uid = 1
|
||||||
try:
|
try:
|
||||||
tool = eval(self.app.defaults["tools_ncc_tools"])[0]
|
tool = eval(str(self.app.defaults["tools_ncc_tools"]))[0]
|
||||||
except TypeError:
|
except TypeError:
|
||||||
tool = eval(self.app.defaults["tools_ncc_tools"])
|
tool = eval(self.app.defaults["tools_ncc_tools"])
|
||||||
|
|
||||||
|
|
|
@ -259,7 +259,7 @@ class TclCommandCopperClear(TclCommand):
|
||||||
margin=margin,
|
margin=margin,
|
||||||
has_offset=has_offset,
|
has_offset=has_offset,
|
||||||
offset=offset,
|
offset=offset,
|
||||||
method=method,
|
method=method_data,
|
||||||
outname=outname,
|
outname=outname,
|
||||||
connect=connect,
|
connect=connect,
|
||||||
contour=contour,
|
contour=contour,
|
||||||
|
@ -290,7 +290,7 @@ class TclCommandCopperClear(TclCommand):
|
||||||
margin=margin,
|
margin=margin,
|
||||||
has_offset=has_offset,
|
has_offset=has_offset,
|
||||||
offset=offset,
|
offset=offset,
|
||||||
method=method,
|
method=method_data,
|
||||||
outname=outname,
|
outname=outname,
|
||||||
connect=connect,
|
connect=connect,
|
||||||
contour=contour,
|
contour=contour,
|
||||||
|
|
|
@ -93,8 +93,8 @@ class TclCommandMillDrills(TclCommandSignaled):
|
||||||
else:
|
else:
|
||||||
args['use_thread'] = False
|
args['use_thread'] = False
|
||||||
|
|
||||||
if not obj.drills:
|
# if not obj.drills:
|
||||||
self.raise_tcl_error("The Excellon object has no drills: %s" % name)
|
# self.raise_tcl_error("The Excellon object has no drills: %s" % name)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if 'milled_dias' in args and args['milled_dias'] != 'all':
|
if 'milled_dias' in args and args['milled_dias'] != 'all':
|
||||||
|
|
|
@ -0,0 +1,48 @@
|
||||||
|
from tclCommands.TclCommand import *
|
||||||
|
from PyQt5.QtWidgets import QFileDialog
|
||||||
|
|
||||||
|
|
||||||
|
class TclCommandOpenFolder(TclCommand):
|
||||||
|
"""
|
||||||
|
Tcl shell command to get open a folder browser dialog and return the result
|
||||||
|
|
||||||
|
example:
|
||||||
|
open_folder
|
||||||
|
"""
|
||||||
|
|
||||||
|
# List of all command aliases, to be able use old names for backward compatibility (add_poly, add_polygon)
|
||||||
|
aliases = ['open_folder']
|
||||||
|
|
||||||
|
# Dictionary of types from Tcl command, needs to be ordered
|
||||||
|
arg_names = collections.OrderedDict()
|
||||||
|
|
||||||
|
# Dictionary of types from Tcl command, needs to be ordered , this is for options like -optionname value
|
||||||
|
option_types = collections.OrderedDict([
|
||||||
|
('dir', str)
|
||||||
|
])
|
||||||
|
|
||||||
|
# array of mandatory options for current Tcl command: required = {'name','outname'}
|
||||||
|
required = []
|
||||||
|
|
||||||
|
# structured help for current command, args needs to be ordered
|
||||||
|
help = {
|
||||||
|
'main': "Opens a dialog to browse for a folder",
|
||||||
|
'args': collections.OrderedDict([
|
||||||
|
('dir', 'Initial directory to open')
|
||||||
|
]),
|
||||||
|
'examples': ['open_folder']
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
"""
|
||||||
|
if "dir" in args:
|
||||||
|
return QFileDialog.getExistingDirectory(dir=args['dir'])
|
||||||
|
else:
|
||||||
|
return QFileDialog.getExistingDirectory()
|
|
@ -0,0 +1,63 @@
|
||||||
|
from tclCommands.TclCommand import TclCommand
|
||||||
|
from appObjects.FlatCAMGeometry import GeometryObject
|
||||||
|
|
||||||
|
import collections
|
||||||
|
from copy import deepcopy
|
||||||
|
|
||||||
|
|
||||||
|
class TclCommandSplitGeometry(TclCommand):
|
||||||
|
"""
|
||||||
|
Tcl shell command to split a geometry by tools.
|
||||||
|
|
||||||
|
example:
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
# List of all command aliases, to be able use old names for backward compatibility (add_poly, add_polygon)
|
||||||
|
aliases = ['split_geometries', 'split_geometry']
|
||||||
|
|
||||||
|
description = '%s %s' % (
|
||||||
|
"--", "Split one Geometry object into separate ones for each tool.")
|
||||||
|
|
||||||
|
# Dictionary of types from Tcl command, needs to be ordered
|
||||||
|
arg_names = collections.OrderedDict([
|
||||||
|
('source_name', 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 = ['source_name']
|
||||||
|
|
||||||
|
# structured help for current command, args needs to be ordered
|
||||||
|
help = {
|
||||||
|
'main': "Creates a new geometry for every tool and fills it with the tools geometry data",
|
||||||
|
'args': collections.OrderedDict([
|
||||||
|
('source_name', 'Name of the source Geometry Object. Required'),
|
||||||
|
]),
|
||||||
|
'examples': ['split_geometry my_geometry']
|
||||||
|
}
|
||||||
|
|
||||||
|
def execute(self, args, unnamed_args):
|
||||||
|
"""
|
||||||
|
|
||||||
|
:param args:
|
||||||
|
:param unnamed_args:
|
||||||
|
:return:
|
||||||
|
"""
|
||||||
|
|
||||||
|
obj: GeometryObject = self.app.collection.get_by_name(
|
||||||
|
str(args['source_name']))
|
||||||
|
if obj is None:
|
||||||
|
return "Object not found: %s" % args['source_name']
|
||||||
|
|
||||||
|
for uid in list(obj.tools.keys()):
|
||||||
|
def initialize(new_obj, app):
|
||||||
|
new_obj.multigeo = True
|
||||||
|
new_obj.tools[uid] = deepcopy(obj.tools[uid])
|
||||||
|
name = "{0}_tool_{1}".format(args['source_name'], uid)
|
||||||
|
self.app.app_obj.new_object(
|
||||||
|
"geometry", name, initialize, plot=False)
|
|
@ -45,6 +45,7 @@ import tclCommands.TclCommandNewGerber
|
||||||
import tclCommands.TclCommandOffset
|
import tclCommands.TclCommandOffset
|
||||||
import tclCommands.TclCommandOpenDXF
|
import tclCommands.TclCommandOpenDXF
|
||||||
import tclCommands.TclCommandOpenExcellon
|
import tclCommands.TclCommandOpenExcellon
|
||||||
|
import tclCommands.TclCommandOpenFolder
|
||||||
import tclCommands.TclCommandOpenGCode
|
import tclCommands.TclCommandOpenGCode
|
||||||
import tclCommands.TclCommandOpenGerber
|
import tclCommands.TclCommandOpenGerber
|
||||||
import tclCommands.TclCommandOpenProject
|
import tclCommands.TclCommandOpenProject
|
||||||
|
@ -63,6 +64,7 @@ import tclCommands.TclCommandSetOrigin
|
||||||
import tclCommands.TclCommandSetPath
|
import tclCommands.TclCommandSetPath
|
||||||
import tclCommands.TclCommandSetSys
|
import tclCommands.TclCommandSetSys
|
||||||
import tclCommands.TclCommandSkew
|
import tclCommands.TclCommandSkew
|
||||||
|
import tclCommands.TclCommandSplitGeometry
|
||||||
import tclCommands.TclCommandSubtractPoly
|
import tclCommands.TclCommandSubtractPoly
|
||||||
import tclCommands.TclCommandSubtractRectangle
|
import tclCommands.TclCommandSubtractRectangle
|
||||||
import tclCommands.TclCommandVersion
|
import tclCommands.TclCommandVersion
|
||||||
|
@ -93,7 +95,8 @@ def register_all_commands(app, commands):
|
||||||
:return: None
|
:return: None
|
||||||
"""
|
"""
|
||||||
|
|
||||||
tcl_modules = {k: v for k, v in list(sys.modules.items()) if k.startswith('tclCommands.TclCommand')}
|
tcl_modules = {k: v for k, v in list(
|
||||||
|
sys.modules.items()) if k.startswith('tclCommands.TclCommand')}
|
||||||
|
|
||||||
for key, mod in list(tcl_modules.items()):
|
for key, mod in list(tcl_modules.items()):
|
||||||
if key != 'tclCommands.TclCommand':
|
if key != 'tclCommands.TclCommand':
|
||||||
|
|
Loading…
Reference in New Issue