fixes in filter layer, added guide support for migrategroups

This commit is contained in:
Mario Voigt 2021-04-19 22:07:01 +02:00
parent db8f6be2a5
commit 70ffb2b72f
6 changed files with 51 additions and 47 deletions

View File

@ -0,0 +1,2 @@
eclipse.preferences.version=1
encoding//extensions/fablabchemnitz/create_links.py=utf-8

View File

@ -55,8 +55,8 @@ class Cleanup(inkex.EffectExtension):
if len(self.svg.selected) == 0:
self.getAttribs(self.document.getroot())
else:
for id, node in self.svg.selected.items():
self.getAttribs(node)
for element in self.svg.selected.values():
self.getAttribs(element)
#finally remove the styles from collected groups (if enabled)
if self.options.remove_group_styles is True:
for group in self.groups:

View File

@ -289,16 +289,16 @@ class ContourScanner(inkex.EffectExtension):
self.scanContours(self.document.getroot())
else:
newContourSet = []
for id, item in self.svg.selected.items():
self.breakContours(item)
for element in self.svg.selected.items():
self.breakContours(element)
for newContours in self.replacedNodes:
self.scanContours(newContours)
else:
if len(self.svg.selected) == 0:
self.scanContours(self.document.getroot())
else:
for id, item in self.svg.selected.items():
self.scanContours(item)
for element in self.svg.selected.values():
self.scanContours(element)
if __name__ == '__main__':
ContourScanner().run()

View File

@ -1,6 +1,6 @@
#!/usr/bin/env python3
'''
This extension adds or removes filters to current layer
This extension adds filters to current layer or removes filters from current layer
Copyright (C) 2012 Jabiertxo Arraiza, jabier.arraiza@marker.es
@ -37,15 +37,11 @@ class FilterAndLiveEffectsLayer(inkex.EffectExtension):
pars.add_argument('--type', default = 'Add', help = 'Add or remove filters to current layer')
def selectTop(self):
selected = []
selectedSorted = None
if self.svg.selected is not None:
for id, node in self.svg.selected.items():
selected.append(id)
for node in self.document.getroot().iter():
idNode = node.get("id")
if idNode in selected:
selectedSorted = node
for element in self.document.getroot().iter():
if element.get("id") in self.svg.selection:
selectedSorted = element
return selectedSorted
def effect(self):
@ -56,7 +52,8 @@ class FilterAndLiveEffectsLayer(inkex.EffectExtension):
idLayer = namedview[0].get('{http://www.inkscape.org/namespaces/inkscape}current-layer');
xpathStr = '//svg:g[@id="'+idLayer+'"]'
layer = svg.xpath(xpathStr, namespaces=inkex.NSS)
if typeOperation == "Add":
if typeOperation == "Add": #Add action
element = self.selectTop()
if element is not None:
if element.get('style'):
@ -74,6 +71,7 @@ class FilterAndLiveEffectsLayer(inkex.EffectExtension):
layer[0].set('style',filter)
else:
inkex.utils.debug("Nothing selected")
else: #Remove action
if layer[0].get('style'):
matchObj = re.search( r'filter:url\(#.*?[^\)]\)', layer[0].get('style'), re.M|re.I)

View File

@ -45,12 +45,13 @@
<param name="clipPath" type="bool" gui-text="clipPath">true</param>
<param name="defs" type="bool" gui-text="defs">true</param>
<param name="image" type="bool" gui-text="image">true</param>
<param name="guide" type="bool" gui-text="guide">true</param>
<param name="mask" type="bool" gui-text="mask">true</param>
<param name="marker" type="bool" gui-text="marker">true</param>
<param name="metadata" type="bool" gui-text="metadata">true</param>
</vbox>
<spacer/>
<vbox>
<param name="metadata" type="bool" gui-text="metadata">true</param>
<param name="pattern" type="bool" gui-text="pattern">true</param>
<param name="script" type="bool" gui-text="script">true</param>
<param name="switch" type="bool" gui-text="switch">true</param>

View File

@ -39,6 +39,7 @@ class MigrateGroups(inkex.EffectExtension):
pars.add_argument("--defs", type=inkex.Boolean, default=True)
pars.add_argument("--ellipse", type=inkex.Boolean, default=True)
pars.add_argument("--image", type=inkex.Boolean, default=True)
pars.add_argument("--guide", type=inkex.Boolean, default=True)
pars.add_argument("--line", type=inkex.Boolean, default=True)
pars.add_argument("--path", type=inkex.Boolean, default=True)
pars.add_argument("--polyline", type=inkex.Boolean, default=True)
@ -98,6 +99,8 @@ class MigrateGroups(inkex.EffectExtension):
namespace.append("{http://www.w3.org/2000/svg}flowPara") if self.options.flowPara else ""
namespace.append("{http://www.w3.org/2000/svg}marker") if self.options.marker else ""
namespace.append("{http://www.w3.org/2000/svg}pattern") if self.options.pattern else ""
namespace.append("{http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd}guide") if self.options.guide else ""
#self.msg(namespace)
#in case the user made a manual selection instead of whole document parsing, we need to collect all required elements first