small enhancements

This commit is contained in:
Mario Voigt 2021-10-19 14:07:12 +02:00
parent 207ae044fe
commit 3ed7e2ae3a
4 changed files with 17 additions and 11 deletions

View File

@ -8,6 +8,7 @@
<vbox> <vbox>
<label appearance="header">Join Paths</label> <label appearance="header">Join Paths</label>
<param name="optimized" type="bool" gui-text="Optimized joining">true</param> <param name="optimized" type="bool" gui-text="Optimized joining">true</param>
<param name="reverse" type="bool" gui-text="Reverse">true</param>
<param name="margin" type="float" min="0.0001" max="99999.0000" precision="4" gui-text="Merge margin">0.0100</param> <param name="margin" type="float" min="0.0001" max="99999.0000" precision="4" gui-text="Merge margin">0.0100</param>
<label appearance="header">Tabs And Dimples</label> <label appearance="header">Tabs And Dimples</label>
<label>Enable to insert dimples (pressfit noses) into</label> <label>Enable to insert dimples (pressfit noses) into</label>

View File

@ -126,6 +126,7 @@ class JoinPaths(inkex.EffectExtension):
def add_arguments(self, pars): def add_arguments(self, pars):
pars.add_argument("--optimized", type=inkex.Boolean, default=True) pars.add_argument("--optimized", type=inkex.Boolean, default=True)
pars.add_argument("--reverse", type=inkex.Boolean, default=False)
pars.add_argument("--margin", type=float, default=0.0100) pars.add_argument("--margin", type=float, default=0.0100)
pars.add_argument("--add_dimples", type=inkex.Boolean, default=False) pars.add_argument("--add_dimples", type=inkex.Boolean, default=False)
pars.add_argument("--draw_dimple_centers", type=inkex.Boolean, default=False) pars.add_argument("--draw_dimple_centers", type=inkex.Boolean, default=False)
@ -146,23 +147,24 @@ class JoinPaths(inkex.EffectExtension):
pars.add_argument("--tab", default="sampling", help="Tab") pars.add_argument("--tab", default="sampling", help="Tab")
def effect(self): def effect(self):
selections = self.svg.selected
if len(self.svg.selected) == 0:
self.msg('Please select some paths first.')
return
pathNodes = self.document.xpath('//svg:path',namespaces=inkex.NSS) pathNodes = self.document.xpath('//svg:path',namespaces=inkex.NSS)
paths = {p.get('id'): getPartsFromCubicSuper(CubicSuperPath(p.get('d'))) for p in pathNodes } if self.options.reverse is True: #helps debugging some strange Z orders (try out)
pathNodes = pathNodes[::-1]
#pathNodes[0].path = pathNodes[0].path.reverse()
#pathNodes[0].path = pathNodes[-1].path.reverse()
paths = {p.get('id'): getPartsFromCubicSuper(CubicSuperPath(p.get('d'))) for p in pathNodes }
#paths.keys() Order disturbed #paths.keys() Order disturbed
pathIds = [p.get('id') for p in pathNodes] pathIds = [p.get('id') for p in pathNodes]
if self.options.dimples_to_group is True: if self.options.dimples_to_group is True:
dimpleUnifyGroup = self.svg.get_current_layer().add(inkex.Group(id=self.svg.get_unique_id("dimplesCollection"))) dimpleUnifyGroup = self.svg.get_current_layer().add(inkex.Group(id=self.svg.get_unique_id("dimplesCollection")))
if(len(paths) > 1): if(len(paths) > 1):
if(self.options.optimized): if(self.options.optimized):
startPathId = pathIds[0] startPathId = pathIds[0]
pathIds = getArrangedIds(paths, startPathId) pathIds = getArrangedIds(paths, startPathId)
newParts = [] newParts = []
firstElem = None firstElem = None
for key in pathIds: for key in pathIds:
@ -171,7 +173,7 @@ class JoinPaths(inkex.EffectExtension):
start = parts[0][0][0] start = parts[0][0][0]
try: try:
elem = self.svg.selected[key] elem = self.svg.selected[key]
if(len(newParts) == 0): if(len(newParts) == 0):
newParts += parts[:] newParts += parts[:]
firstElem = elem firstElem = elem
@ -373,6 +375,9 @@ class JoinPaths(inkex.EffectExtension):
except: except:
pass #elem might come from group item - in this case we need to ignore it pass #elem might come from group item - in this case we need to ignore it
if firstElem is None:
self.msg('Please select some paths first. Check if you selected a group or an object instead.')
exit()
newElem = copy.copy(firstElem) newElem = copy.copy(firstElem)
oldId = firstElem.get('id') oldId = firstElem.get('id')
newElem.set('d', CubicSuperPath(getCubicSuperFromParts(newParts))) newElem.set('d', CubicSuperPath(getCubicSuperFromParts(newParts)))

View File

@ -11,7 +11,7 @@
"source_url": "https://gitea.fablabchemnitz.de/FabLab_Chemnitz/mightyscape-1.X/src/branch/master/extensions/fablabchemnitz/mirror", "source_url": "https://gitea.fablabchemnitz.de/FabLab_Chemnitz/mightyscape-1.X/src/branch/master/extensions/fablabchemnitz/mirror",
"fork_url": "https://inkscape.org/~jeko/%E2%98%85mirror", "fork_url": "https://inkscape.org/~jeko/%E2%98%85mirror",
"documentation_url": "https://stadtfabrikanten.org/display/IFM/Mirror", "documentation_url": "https://stadtfabrikanten.org/display/IFM/Mirror",
"inkscape_gallery_url": "https://inkscape.org/~MarioVoigt/%E2%98%85move-path-node", "inkscape_gallery_url": null,
"main_authors": [ "main_authors": [
"inkscape.org/jeko", "inkscape.org/jeko",
"github.com/vmario89" "github.com/vmario89"

View File

@ -11,7 +11,7 @@
"source_url": "https://gitea.fablabchemnitz.de/FabLab_Chemnitz/mightyscape-1.X/src/branch/master/extensions/fablabchemnitz/move_path_node", "source_url": "https://gitea.fablabchemnitz.de/FabLab_Chemnitz/mightyscape-1.X/src/branch/master/extensions/fablabchemnitz/move_path_node",
"fork_url": null, "fork_url": null,
"documentation_url": "https://stadtfabrikanten.org/display/IFM/Move+Path+Node", "documentation_url": "https://stadtfabrikanten.org/display/IFM/Move+Path+Node",
"inkscape_gallery_url": null, "inkscape_gallery_url": "https://inkscape.org/~MarioVoigt/%E2%98%85move-path-node",
"main_authors": [ "main_authors": [
"github.com/vmario89" "github.com/vmario89"
] ]