added duplicate,reverse,join
This commit is contained in:
parent
4bf4d810fe
commit
207ae044fe
@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension">
|
||||
<name>Duplicate + Reverse + Join</name>
|
||||
<id>fablabchemnitz.de.duplicate_reverse_join</id>
|
||||
<effect>
|
||||
<effects-menu>
|
||||
<submenu name="FabLab Chemnitz">
|
||||
<submenu name="Modify existing Path(s)"/>
|
||||
</submenu>
|
||||
</effects-menu>
|
||||
</effect>
|
||||
<script>
|
||||
<command location="inx" interpreter="python">duplicate_reverse_join.py</command>
|
||||
</script>
|
||||
</inkscape-extension>
|
@ -0,0 +1,63 @@
|
||||
#!/usr/bin/env python3
|
||||
#
|
||||
# Copyright (C) 2020 Ellen Wasboe, ellen@wasbo.net
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
"""
|
||||
Duplicate subpaths of all selected paths, reverse and join end nodes.
|
||||
"""
|
||||
|
||||
import inkex
|
||||
|
||||
class DuplicateReverseJoin(inkex.EffectExtension):
|
||||
|
||||
def effect(self):
|
||||
for elem in self.svg.selection:
|
||||
|
||||
pp=elem.path.to_absolute()
|
||||
dList=str(pp).split(' M')
|
||||
dFinal=''
|
||||
l=0
|
||||
for sub in dList:
|
||||
if l>0:
|
||||
origSub='M'+dList[l]
|
||||
else:
|
||||
origSub=dList[l]
|
||||
|
||||
elem.path=origSub
|
||||
reSub=elem.path.reverse()
|
||||
|
||||
if l>0:
|
||||
origSub=' '+origSub
|
||||
|
||||
if origSub.find('Z') > -1:
|
||||
dRev=str(reSub).split(' ')
|
||||
strRev=''
|
||||
if dRev[3]=='L' and dRev[1]==dRev[4] and dRev[2]==dRev[5]:
|
||||
strRev=' '.join(dRev[0:3])+' '+' '.join(dRev[6:]) #avoid that reverse path duplicate first node
|
||||
else:
|
||||
strRev=' '.join(dRev)
|
||||
dFinal=dFinal+origSub+' '+strRev #keep original and reverse as separate closed paths
|
||||
if dRev[-1]!='Z':
|
||||
dFinal=dFinal+' Z'#avoid that reverse of closed path is open
|
||||
else:
|
||||
dRev=str(reSub).split(' ')
|
||||
dFinal=dFinal+origSub+' '+' '.join(dRev[3:])+' Z' #pop off M element of reverse path and add Z to close
|
||||
l+=1
|
||||
elem.path=dFinal
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
DuplicateReverseJoin().run()
|
20
extensions/fablabchemnitz/duplicate_reverse_join/meta.json
Normal file
20
extensions/fablabchemnitz/duplicate_reverse_join/meta.json
Normal file
@ -0,0 +1,20 @@
|
||||
[
|
||||
{
|
||||
"name": "Duplicate + Reverse + Join",
|
||||
"id": "fablabchemnitz.de.duplicate_reverse_join",
|
||||
"path": "duplicate_reverse_join",
|
||||
"original_name": "Duplicate, reverse, join",
|
||||
"original_id": "EllenWasbo.cutlings.duplicateReverseJoin",
|
||||
"license": "GNU GPL v2",
|
||||
"license_url": "https://gitlab.com/EllenWasbo/inkscape-extension-duplicatereversejoin/-/blob/master/duplicateReverseJoin.py",
|
||||
"comment": "",
|
||||
"source_url": "https://gitea.fablabchemnitz.de/FabLab_Chemnitz/mightyscape-1.X/src/branch/master/extensions/fablabchemnitz/duplicate_reverse_joi",
|
||||
"fork_url": "https://gitlab.com/EllenWasbo/inkscape-extension-duplicatereversejoin",
|
||||
"documentation_url": "https://stadtfabrikanten.org/pages/viewpage.action?pageId=120525059",
|
||||
"inkscape_gallery_url": null,
|
||||
"main_authors": [
|
||||
"gitlab.com/EllenWasbo",
|
||||
"github.com/vmario89"
|
||||
]
|
||||
}
|
||||
]
|
Reference in New Issue
Block a user