fix glitchy group cleaning
This commit is contained in:
parent
f37541c505
commit
f388ca774f
@ -5,6 +5,7 @@
|
|||||||
<param name="tab" type="notebook">
|
<param name="tab" type="notebook">
|
||||||
<page name="tab_settings" gui-text="Settings">
|
<page name="tab_settings" gui-text="Settings">
|
||||||
<param name="separateby" gui-text="Separate by" type="optiongroup" appearance="combo">
|
<param name="separateby" gui-text="Separate by" type="optiongroup" appearance="combo">
|
||||||
|
<option value="element_tag">Element tag</option>
|
||||||
<option value="stroke">Stroke color</option>
|
<option value="stroke">Stroke color</option>
|
||||||
<option value="stroke_width">Stroke width</option>
|
<option value="stroke_width">Stroke width</option>
|
||||||
<option value="stroke_hairline">Stroke hairline</option>
|
<option value="stroke_hairline">Stroke hairline</option>
|
||||||
|
@ -8,7 +8,7 @@ Features
|
|||||||
Author: Mario Voigt / FabLab Chemnitz
|
Author: Mario Voigt / FabLab Chemnitz
|
||||||
Mail: mario.voigt@stadtfabrikanten.org
|
Mail: mario.voigt@stadtfabrikanten.org
|
||||||
Date: 19.08.2020
|
Date: 19.08.2020
|
||||||
Last patch: 11.04.2021
|
Last patch: 17.10.2021
|
||||||
License: GNU GPL v3
|
License: GNU GPL v3
|
||||||
"""
|
"""
|
||||||
import inkex
|
import inkex
|
||||||
@ -115,7 +115,11 @@ class StylesToLayers(inkex.EffectExtension):
|
|||||||
#the Styles to Layers extension still might brick the gradients (some tests failed)
|
#the Styles to Layers extension still might brick the gradients (some tests failed)
|
||||||
if style and element.tag != inkex.addNS('stop','svg') and element.tag != inkex.addNS('tspan','svg'):
|
if style and element.tag != inkex.addNS('stop','svg') and element.tag != inkex.addNS('tspan','svg'):
|
||||||
|
|
||||||
if self.options.separateby == "stroke":
|
if self.options.separateby == "element_tag":
|
||||||
|
neutral_value = 1
|
||||||
|
layer_name = "element_tag-" + element.tag.replace("{http://www.w3.org/2000/svg}", "")
|
||||||
|
|
||||||
|
elif self.options.separateby == "stroke":
|
||||||
stroke = re.search('(;|^)stroke:(.*?)(;|$)', style)
|
stroke = re.search('(;|^)stroke:(.*?)(;|$)', style)
|
||||||
if stroke is not None:
|
if stroke is not None:
|
||||||
stroke = stroke[0]
|
stroke = stroke[0]
|
||||||
@ -287,6 +291,12 @@ class StylesToLayers(inkex.EffectExtension):
|
|||||||
for newLayerNode in topLevelLayerNodeList:
|
for newLayerNode in topLevelLayerNodeList:
|
||||||
newLayerNode[0].append(newLayerNode[1]) #append newlayer to layer
|
newLayerNode[0].append(newLayerNode[1]) #append newlayer to layer
|
||||||
|
|
||||||
|
#clean all empty layers from node list. Please note that the following remove_empty_groups
|
||||||
|
#call does not apply for this so we need to do it as PREVIOUS step before!
|
||||||
|
for i in range(0, len(layerNodeList)):
|
||||||
|
if len(layerNodeList[i][0]) == 0:
|
||||||
|
layerNodeList[i][0].getparent().remove(layerNodeList[i][0])
|
||||||
|
|
||||||
if self.options.cleanup == True:
|
if self.options.cleanup == True:
|
||||||
try:
|
try:
|
||||||
import remove_empty_groups
|
import remove_empty_groups
|
||||||
|
Reference in New Issue
Block a user