Hole milling is functional. Solves issue #74.

This commit is contained in:
Juan Pablo Caram 2014-12-09 21:30:01 -05:00
parent fe2b4c7478
commit f68cffcfb2
3 changed files with 26 additions and 6 deletions

View File

@ -84,9 +84,11 @@ class App(QtCore.QObject):
App.log.debug("Win32!")
self.data_path = shell.SHGetFolderPath(0, shellcon.CSIDL_APPDATA, None, 0) + \
'/FlatCAM'
self.os = 'windows'
else: # Linux/Unix/MacOS
self.data_path = os.path.expanduser('~') + \
'/.FlatCAM'
self.os = 'unix'
###############################
### Setup folders and files ###

View File

@ -635,13 +635,19 @@ class FlatCAMExcellon(FlatCAMObj, Excellon):
self.app.report_usage("excellon_on_create_milling_button")
self.read_form()
# Get the tools from the list
# Get the tools from the list. These are keys
# to self.tools
tools = self.get_selected_tools_list()
if len(tools) == 0:
self.app.inform.emit("Please select one or more tools from the list and try again.")
return
for tool in tools:
if self.tools[tool]["C"] < self.options["tooldia"]:
self.app.inform.emit("[warning] Milling tool is larger than hole size. Cancelled.")
return
geo_name = self.options["name"] + "_mill"
def geo_init(geo_obj, app_obj):
@ -653,7 +659,8 @@ class FlatCAMExcellon(FlatCAMObj, Excellon):
for hole in self.drills:
if hole['tool'] in tools:
geo_obj.solid_geometry.append(
Point(hole['point']).buffer(self.tools[hole['tool']]["C"]/2 - self.options["tooldia"]/2).exterior
Point(hole['point']).buffer(self.tools[hole['tool']]["C"] / 2 -
self.options["tooldia"] / 2).exterior
)
def geo_thread(app_obj):
@ -1121,7 +1128,9 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
try:
for sub_el in element:
self.plot_element(sub_el)
except TypeError:
except TypeError: # Element is not iterable...
if type(element) == Polygon:
x, y = element.exterior.coords.xy
self.axes.plot(x, y, 'r-')
@ -1135,7 +1144,7 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
self.axes.plot(x, y, 'r-')
return
FlatCAMApp.App.log.warning("Did not plot:", str(type(element)))
FlatCAMApp.App.log.warning("Did not plot:" + str(type(element)))
def plot(self):
"""

View File

@ -190,7 +190,16 @@ class Geometry(object):
:rtype: Shapely.MultiPolygon or Shapely.Polygon
"""
return self.solid_geometry.buffer(offset)
def is_empty(self):
if self.solid_geometry is None:
return True
if type(self.solid_geometry) is list and len(self.solid_geometry) == 0:
return True
return False
def size(self):
"""
Returns (width, height) of rectangular
@ -200,7 +209,7 @@ class Geometry(object):
log.warning("Solid_geometry not computed yet.")
return 0
bounds = self.bounds()
return bounds[2]-bounds[0], bounds[3]-bounds[1]
return bounds[2] - bounds[0], bounds[3] - bounds[1]
def get_empty_area(self, boundary=None):
"""