- Film Plugin: fixed error on generation of positive film with punched holes due of the aperture of type "REG" (copper plane / region)

This commit is contained in:
Marius Stanciu
2024-02-20 03:36:36 +02:00
parent e39dbeb5a1
commit d583bb8cf2
2 changed files with 17 additions and 7 deletions

View File

@@ -11,6 +11,7 @@ CHANGELOG for FlatCAM Evo beta
- Punch Gerber Plugin: fixed issues with iterating ovr a MultiPolygon - Punch Gerber Plugin: fixed issues with iterating ovr a MultiPolygon
- GerberObject: fixed Gerber merging functionality - GerberObject: fixed Gerber merging functionality
- Film Plugin: fixed error on generation of positive film with punched holes due of the aperture of type "REG" (copper plane / region)
11.01.2024 11.01.2024

View File

@@ -10,9 +10,12 @@ from appTool import AppTool
from appGUI.GUIElements import VerticalScrollArea, FCLabel, FCButton, FCFrame, GLay, FCComboBox, FCCheckBox, \ from appGUI.GUIElements import VerticalScrollArea, FCLabel, FCButton, FCFrame, GLay, FCComboBox, FCCheckBox, \
FCComboBox2, RadioSet, FCDoubleSpinner, FCSpinner, FCFileSaveDialog, OptionalHideInputSection FCComboBox2, RadioSet, FCDoubleSpinner, FCSpinner, FCFileSaveDialog, OptionalHideInputSection
from camlib import flatten_shapely_geometry
import logging import logging
from copy import deepcopy from copy import deepcopy
import math import math
import simplejson as json
from shapely import LineString, MultiPolygon, Point, Polygon, LinearRing from shapely import LineString, MultiPolygon, Point, Polygon, LinearRing
from shapely.affinity import scale, skew from shapely.affinity import scale, skew
@@ -457,33 +460,39 @@ class Film(AppTool):
punching_geo = [] punching_geo = []
for apid in film_obj.tools: for apid in film_obj.tools:
if film_obj.tools[apid]['type'] == 'C': print(film_obj.tools.get(apid, {}))
if punch_size >= float(film_obj.tools[apid]['size']): aperture_type = film_obj.tools.get(apid, {}).get('type', '')
if aperture_type == 'C':
aperture_size = float(film_obj.tools.get(apid, {}).get('size', 0.0))
if punch_size >= aperture_size:
self.app.inform.emit('[ERROR_NOTCL] %s' % self.app.inform.emit('[ERROR_NOTCL] %s' %
_("Failed. Punch hole size " _("Failed. Punch hole size "
"is bigger than some of the apertures in the Gerber object.")) "is bigger than some of the apertures in the Gerber object."))
return 'fail' return 'fail'
else: else:
for elem in film_obj.tools[apid]['geometry']: for elem in film_obj.tools.get(apid, {}).get('geometry', []):
if 'follow' in elem: if 'follow' in elem:
if isinstance(elem['follow'], Point): if isinstance(elem['follow'], Point):
punching_geo.append(elem['follow'].buffer(punch_size / 2)) punching_geo.append(elem['follow'].buffer(punch_size / 2))
elif aperture_type == "REG":
pass
else: else:
if punch_size >= float(film_obj.tools[apid]['width']) or \ aperture_width = float(film_obj.tools.get(apid, {}).get('width', 0.0))
punch_size >= float(film_obj.tools[apid]['height']): aperture_height = float(film_obj.tools.get(apid, {}).get('height', 0.0))
if punch_size >= aperture_width or punch_size >= aperture_height:
self.app.inform.emit('[ERROR_NOTCL] %s' % self.app.inform.emit('[ERROR_NOTCL] %s' %
_("Failed. Punch hole size " _("Failed. Punch hole size "
"is bigger than some of the apertures in the Gerber object.")) "is bigger than some of the apertures in the Gerber object."))
return 'fail' return 'fail'
else: else:
for elem in film_obj.tools[apid]['geometry']: for elem in flatten_shapely_geometry(film_obj.tools.get(apid, {}).get('geometry', [])):
if 'follow' in elem: if 'follow' in elem:
if isinstance(elem['follow'], Point): if isinstance(elem['follow'], Point):
punching_geo.append(elem['follow'].buffer(punch_size / 2)) punching_geo.append(elem['follow'].buffer(punch_size / 2))
punching_geo = MultiPolygon(punching_geo) punching_geo = MultiPolygon(punching_geo)
if not isinstance(film_obj.solid_geometry, Polygon): if not isinstance(film_obj.solid_geometry, Polygon):
temp_solid_geometry = MultiPolygon(film_obj.solid_geometry) temp_solid_geometry = MultiPolygon(flatten_shapely_geometry(film_obj.solid_geometry))
else: else:
temp_solid_geometry = film_obj.solid_geometry temp_solid_geometry = film_obj.solid_geometry
punched_solid_geometry = temp_solid_geometry.difference(punching_geo) punched_solid_geometry = temp_solid_geometry.difference(punching_geo)