add filter check for laser check

This commit is contained in:
Mario Voigt 2021-12-07 12:50:24 +01:00
parent aecbd00c1e
commit be95fae2b8
2 changed files with 31 additions and 0 deletions

View File

@ -24,6 +24,7 @@
<param name="clippaths" type="bool" gui-text="Clippings">false</param>
<param name="images" type="bool" gui-text="Images">false</param>
<param name="texts" type="bool" gui-text="Texts">false</param>
<param name="filters" type="bool" gui-text="Filters">false</param>
<param name="lowlevelstrokes" type="bool" gui-text="Low level strokes">false</param>
<separator/>
<param name="stroke_colors" type="bool" gui-text="Stroke colors">false</param>

View File

@ -80,6 +80,7 @@ class LaserCheck(inkex.EffectExtension):
pars.add_argument('--clippaths', type=inkex.Boolean, default=False)
pars.add_argument('--images', type=inkex.Boolean, default=False)
pars.add_argument('--texts', type=inkex.Boolean, default=False)
pars.add_argument('--filters', type=inkex.Boolean, default=False)
pars.add_argument('--lowlevelstrokes', type=inkex.Boolean, default=False)
pars.add_argument('--stroke_colors', type=inkex.Boolean, default=False)
pars.add_argument('--stroke_colors_max', type=int, default=3)
@ -347,6 +348,34 @@ class LaserCheck(inkex.EffectExtension):
inkex.utils.debug("id={}".format(text.get('id')))
'''
Filters on elements let Epilog Software Suite always think vectors should get to raster image data. That might be good sometimes,
but not in usual case.
'''
if so.checks == "check_all" or so.filters is True:
inkex.utils.debug("\n---------- Filters (should be removed to keep vector characterism)")
filter_elements = []
for element in selected:
if element.tag == inkex.addNS('filter','svg'):
filter_elements.append(element)
filter_styles = []
if so.show_issues_only is False:
inkex.utils.debug("{} filters (as svg:filter) in total".format(len(filter_elements)))
for filter_element in filter_elements:
inkex.utils.debug("id={}".format(filter_element.get('id')))
for element in selected:
filter_style = [element, element.style.get('filter')]
if filter_style[1] is None or filter_style[1] == "none":
filter_style[1] = "none"
if filter_style[1] != "none" and filter_style not in filter_styles:
filter_styles.append(filter_style)
if so.show_issues_only is False:
inkex.utils.debug("{} filters (in styles) in total".format(len(filter_styles)))
for filter_style in filter_styles:
inkex.utils.debug("id={}, filter={}".format(filter_style[0].get('id'), filter_style[1]))
'''
The more stroke colors the more laser job configuration is required. Reduce the SVG file
@ -499,6 +528,7 @@ class LaserCheck(inkex.EffectExtension):
for transparency in transparencies:
inkex.utils.debug("id={}, transparency={}".format(transparency[0].get('id'), transparency[1]))
'''
We look for paths which are just points. Those are useless in case of lasercutting.
Note: this scan only works for paths, not for subpaths. If so, you need to break apart before