- Convert Any to Excellon. Finished Gerber object conversion to Excellon. Flash's are converted to drills. Traces in the form of a linear LineString (no changes in direction) are converted to slots.
This commit is contained in:
@@ -7,6 +7,10 @@ CHANGELOG for FlatCAM beta
|
|||||||
|
|
||||||
=================================================
|
=================================================
|
||||||
|
|
||||||
|
6.07.2020
|
||||||
|
|
||||||
|
- Convert Any to Excellon. Finished Gerber object conversion to Excellon. Flash's are converted to drills. Traces in the form of a linear LineString (no changes in direction) are converted to slots.
|
||||||
|
|
||||||
2.07.2020
|
2.07.2020
|
||||||
|
|
||||||
- trying to optimize the resulting geometry in DXF import (and in SVG import) by merging contiguous lines; reduced the lines to about one third of the original
|
- trying to optimize the resulting geometry in DXF import (and in SVG import) by merging contiguous lines; reduced the lines to about one third of the original
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ class Excellon(Geometry):
|
|||||||
================ ====================================
|
================ ====================================
|
||||||
tooldia Diameter of the tool
|
tooldia Diameter of the tool
|
||||||
drills List that store the Shapely Points for drill points
|
drills List that store the Shapely Points for drill points
|
||||||
slots List that store the Shapely Points for slots. Each is a tuple: (start_point, stop_point
|
slots List that store the Shapely Points for slots. Each is a tuple: (start_point, stop_point)
|
||||||
data dictionary which holds the options for each tool
|
data dictionary which holds the options for each tool
|
||||||
solid_geometry Geometry list for each tool
|
solid_geometry Geometry list for each tool
|
||||||
================ ====================================
|
================ ====================================
|
||||||
|
|||||||
112
app_Main.py
112
app_Main.py
@@ -5320,40 +5320,100 @@ class App(QtCore.QObject):
|
|||||||
obj_init.solid_geometry = unary_union(obj_init.solid_geometry)
|
obj_init.solid_geometry = unary_union(obj_init.solid_geometry)
|
||||||
|
|
||||||
def initialize_gerber(obj_init, app):
|
def initialize_gerber(obj_init, app):
|
||||||
apertures = {}
|
tools = {}
|
||||||
|
tooluid = 1
|
||||||
|
|
||||||
apid = 10
|
obj_init.solid_geometry = []
|
||||||
for tool in obj.tools:
|
|
||||||
apertures[str(apid)] = {}
|
|
||||||
apertures[str(apid)]['geometry'] = []
|
|
||||||
for geo in obj.tools[tool]['solid_geometry']:
|
|
||||||
new_el = {}
|
|
||||||
new_el['solid'] = geo
|
|
||||||
new_el['follow'] = geo.exterior
|
|
||||||
apertures[str(apid)]['geometry'].append(deepcopy(new_el))
|
|
||||||
|
|
||||||
apertures[str(apid)]['size'] = float(obj.tools[tool]['C'])
|
for apid in obj.apertures:
|
||||||
apertures[str(apid)]['type'] = 'C'
|
if 'geometry' in obj.apertures[apid]:
|
||||||
apid += 1
|
for geo_dict in obj.apertures[apid]['geometry']:
|
||||||
|
if 'follow' in geo_dict:
|
||||||
|
if isinstance(geo_dict['follow'], Point):
|
||||||
|
geo = geo_dict['solid']
|
||||||
|
minx, miny, maxx, maxy = geo.bounds
|
||||||
|
new_dia = min([maxx - minx, maxy - miny])
|
||||||
|
|
||||||
# create solid_geometry
|
new_drill = geo.centroid
|
||||||
solid_geometry = []
|
new_drill_geo = new_drill.buffer(new_dia / 2.0)
|
||||||
for apid in apertures:
|
|
||||||
for geo_el in apertures[apid]['geometry']:
|
|
||||||
solid_geometry.append(geo_el['solid'])
|
|
||||||
|
|
||||||
solid_geometry = MultiPolygon(solid_geometry)
|
current_tooldias = []
|
||||||
solid_geometry = solid_geometry.buffer(0.0000001)
|
if tools:
|
||||||
|
for tool in tools:
|
||||||
|
if tools[tool] and 'tooldia' in tools[tool]:
|
||||||
|
current_tooldias.append(
|
||||||
|
float('%.*f' % (self.decimals, tools[tool]['tooldia']))
|
||||||
|
)
|
||||||
|
|
||||||
obj_init.solid_geometry = deepcopy(solid_geometry)
|
if float('%.*f' % (self.decimals, new_dia)) in current_tooldias:
|
||||||
obj_init.apertures = deepcopy(apertures)
|
for tool in tools:
|
||||||
# clear the working objects (perhaps not necessary due of Python GC)
|
if float('%.*f' % (self.decimals, tools[tool]["tooldia"])) == float(
|
||||||
apertures.clear()
|
'%.*f' % (self.decimals, new_dia)):
|
||||||
|
if new_drill not in tools[tool]['drills']:
|
||||||
|
tools[tool]['drills'].append(new_drill)
|
||||||
|
tools[tool]['solid_geometry'].append(deepcopy(new_drill_geo))
|
||||||
|
else:
|
||||||
|
tools[tooluid] = {}
|
||||||
|
tools[tooluid]['tooldia'] = new_dia
|
||||||
|
tools[tooluid]['drills'] = [new_drill]
|
||||||
|
tools[tooluid]['slots'] = []
|
||||||
|
tools[tooluid]['solid_geometry'] = [new_drill_geo]
|
||||||
|
tooluid += 1
|
||||||
|
|
||||||
|
try:
|
||||||
|
obj_init.solid_geometry.append(new_drill_geo)
|
||||||
|
except (TypeError, AttributeError):
|
||||||
|
obj_init.solid_geometry = [new_drill_geo]
|
||||||
|
elif isinstance(geo_dict['follow'], LineString):
|
||||||
|
geo_coords = list(geo_dict['follow'].coords)
|
||||||
|
|
||||||
|
# slots can have only a start and stop point and no intermediate points
|
||||||
|
if len(geo_coords) != 2:
|
||||||
|
continue
|
||||||
|
|
||||||
|
geo = geo_dict['solid']
|
||||||
|
try:
|
||||||
|
new_dia = obj.apertures[apid]['size']
|
||||||
|
except Exception:
|
||||||
|
continue
|
||||||
|
|
||||||
|
new_slot = (Point(geo_coords[0]), Point(geo_coords[1]))
|
||||||
|
new_slot_geo = geo
|
||||||
|
|
||||||
|
current_tooldias = []
|
||||||
|
if tools:
|
||||||
|
for tool in tools:
|
||||||
|
if tools[tool] and 'tooldia' in tools[tool]:
|
||||||
|
current_tooldias.append(
|
||||||
|
float('%.*f' % (self.decimals, tools[tool]['tooldia']))
|
||||||
|
)
|
||||||
|
|
||||||
|
if float('%.*f' % (self.decimals, new_dia)) in current_tooldias:
|
||||||
|
for tool in tools:
|
||||||
|
if float('%.*f' % (self.decimals, tools[tool]["tooldia"])) == float(
|
||||||
|
'%.*f' % (self.decimals, new_dia)):
|
||||||
|
if new_slot not in tools[tool]['slots']:
|
||||||
|
tools[tool]['slots'].append(new_slot)
|
||||||
|
tools[tool]['solid_geometry'].append(deepcopy(new_slot_geo))
|
||||||
|
else:
|
||||||
|
tools[tooluid] = {}
|
||||||
|
tools[tooluid]['tooldia'] = new_dia
|
||||||
|
tools[tooluid]['drills'] = []
|
||||||
|
tools[tooluid]['slots'] = [new_slot]
|
||||||
|
tools[tooluid]['solid_geometry'] = [new_slot_geo]
|
||||||
|
tooluid += 1
|
||||||
|
|
||||||
|
try:
|
||||||
|
obj_init.solid_geometry.append(new_slot_geo)
|
||||||
|
except (TypeError, AttributeError):
|
||||||
|
obj_init.solid_geometry = [new_slot_geo]
|
||||||
|
|
||||||
|
obj_init.tools = deepcopy(tools)
|
||||||
|
obj_init.solid_geometry = unary_union(obj_init.solid_geometry)
|
||||||
|
|
||||||
if not self.collection.get_selected():
|
if not self.collection.get_selected():
|
||||||
log.warning("App.convert_any2excellon--> No object selected")
|
log.warning("App.convert_any2excellon--> No object selected")
|
||||||
self.inform.emit('[WARNING_NOTCL] %s' %
|
self.inform.emit('[WARNING_NOTCL] %s' % _("No object is selected. Select an object and try again."))
|
||||||
_("No object is selected. Select an object and try again."))
|
|
||||||
return
|
return
|
||||||
|
|
||||||
for obj in self.collection.get_selected():
|
for obj in self.collection.get_selected():
|
||||||
|
|||||||
Reference in New Issue
Block a user