removed some old code stuff in vpypetools (cleaning)
This commit is contained in:
parent
31ccee2730
commit
8330e64ff4
@ -37,7 +37,7 @@ Extension for InkScape 1.X
|
|||||||
Author: Mario Voigt / FabLab Chemnitz
|
Author: Mario Voigt / FabLab Chemnitz
|
||||||
Mail: mario.voigt@stadtfabrikanten.org
|
Mail: mario.voigt@stadtfabrikanten.org
|
||||||
Date: 02.04.2021
|
Date: 02.04.2021
|
||||||
Last patch: 03.04.2021
|
Last patch: 04.04.2021
|
||||||
License: GNU GPL v3
|
License: GNU GPL v3
|
||||||
|
|
||||||
Used (tested) version of vpype: commit id https://github.com/abey79/vpype/commit/0b0dc8dd7e32998dbef639f9db578c3bff02690b (29.03.2021)
|
Used (tested) version of vpype: commit id https://github.com/abey79/vpype/commit/0b0dc8dd7e32998dbef639f9db578c3bff02690b (29.03.2021)
|
||||||
@ -156,7 +156,7 @@ class vpypetools (inkex.EffectExtension):
|
|||||||
for child in children:
|
for child in children:
|
||||||
convertPath(child)
|
convertPath(child)
|
||||||
|
|
||||||
# inkex.utils.debug(str(applyTransformAvailable)) #check if ApplyTransform Extension is available. If yes we use it
|
# check if ApplyTransform Extension is available. If yes we use it
|
||||||
if self.options.apply_transformations is True and applyTransformAvailable is True:
|
if self.options.apply_transformations is True and applyTransformAvailable is True:
|
||||||
applytransform.ApplyTransform().recursiveFuseTransform(self.document.getroot())
|
applytransform.ApplyTransform().recursiveFuseTransform(self.document.getroot())
|
||||||
|
|
||||||
@ -171,10 +171,6 @@ class vpypetools (inkex.EffectExtension):
|
|||||||
convertPath(item)
|
convertPath(item)
|
||||||
input_bbox = inkex.elements._selected.ElementList.bounding_box(self.svg.selected) # get BoundingBox for selection
|
input_bbox = inkex.elements._selected.ElementList.bounding_box(self.svg.selected) # get BoundingBox for selection
|
||||||
|
|
||||||
# inkex.utils.debug(input_bbox)
|
|
||||||
|
|
||||||
# lc.as_mls() #cast LineString array to MultiLineString
|
|
||||||
|
|
||||||
if len(lc) == 0:
|
if len(lc) == 0:
|
||||||
inkex.errormsg('Selection appears to be empty or does not contain any valid svg:path nodes. Try to cast your objects to paths using CTRL + SHIFT + C or strokes to paths using CTRL + ALT+ C')
|
inkex.errormsg('Selection appears to be empty or does not contain any valid svg:path nodes. Try to cast your objects to paths using CTRL + SHIFT + C or strokes to paths using CTRL + ALT+ C')
|
||||||
return
|
return
|
||||||
@ -183,7 +179,6 @@ class vpypetools (inkex.EffectExtension):
|
|||||||
|
|
||||||
# we add the lineCollection (converted selection) to the vpype document
|
# we add the lineCollection (converted selection) to the vpype document
|
||||||
doc.add(lc, layer_id=None)
|
doc.add(lc, layer_id=None)
|
||||||
#doc.translate(input_bbox.left, input_bbox.top) #wrong units?
|
|
||||||
|
|
||||||
tooling_length_before = doc.length()
|
tooling_length_before = doc.length()
|
||||||
traveling_length_before = doc.pen_up_length()
|
traveling_length_before = doc.pen_up_length()
|
||||||
@ -263,7 +258,6 @@ class vpypetools (inkex.EffectExtension):
|
|||||||
return
|
return
|
||||||
|
|
||||||
# show the vpype document visually
|
# show the vpype document visually
|
||||||
# there are missing options to set pen_width and pen_opacity. This is anchored in "Engine" class
|
|
||||||
if self.options.output_show:
|
if self.options.output_show:
|
||||||
vpype_viewer.show(doc, view_mode=ViewMode.PREVIEW, show_pen_up=self.options.output_trajectories, show_points=False, argv=None) # https://vpype.readthedocs.io/en/stable/api/vpype_viewer.ViewMode.html
|
vpype_viewer.show(doc, view_mode=ViewMode.PREVIEW, show_pen_up=self.options.output_trajectories, show_points=False, argv=None) # https://vpype.readthedocs.io/en/stable/api/vpype_viewer.ViewMode.html
|
||||||
|
|
||||||
@ -281,8 +275,6 @@ class vpypetools (inkex.EffectExtension):
|
|||||||
self.debug(cli_output)
|
self.debug(cli_output)
|
||||||
|
|
||||||
# new parse the SVG file and insert it as new group into the current document tree
|
# new parse the SVG file and insert it as new group into the current document tree
|
||||||
# vpype_svg = etree.parse(output_file).getroot().xpath("//svg:g", namespaces=inkex.NSS)
|
|
||||||
|
|
||||||
# the label id is the number of layer_id=None (will start with 1)
|
# the label id is the number of layer_id=None (will start with 1)
|
||||||
lines = etree.parse(output_file).getroot().xpath("//svg:g[@inkscape:label='1']",namespaces=inkex.NSS)
|
lines = etree.parse(output_file).getroot().xpath("//svg:g[@inkscape:label='1']",namespaces=inkex.NSS)
|
||||||
vpypeLinesGroup = self.document.getroot().add(inkex.Group())
|
vpypeLinesGroup = self.document.getroot().add(inkex.Group())
|
||||||
@ -290,19 +282,10 @@ class vpypetools (inkex.EffectExtension):
|
|||||||
for item in lines:
|
for item in lines:
|
||||||
for child in item.getchildren():
|
for child in item.getchildren():
|
||||||
vpypeLinesGroup.append(child)
|
vpypeLinesGroup.append(child)
|
||||||
# get the output's bounding box size (which might be other size than previous input bounding box, e.g. when using trim feature)
|
|
||||||
# output_bbox = vpypeLinesGroup.bounding_box()
|
|
||||||
|
|
||||||
# when using the trim function the bounding box of the original elements will not match the vpype'd ones. So we need to do some calculation for exact placement
|
|
||||||
#translation = 'translate(' + str(input_bbox.left + self.options.trim_x_margin) + ',' + str(input_bbox.top + self.options.trim_y_margin) + ')' # we use the same translation for trajectory lines
|
|
||||||
#vpypeLinesGroup.attrib['transform'] = translation # disabled because we use PageSize with vpype now
|
|
||||||
vpypeLinesGroupId = self.svg.get_unique_id('vpypetools-lines-')
|
vpypeLinesGroupId = self.svg.get_unique_id('vpypetools-lines-')
|
||||||
vpypeLinesGroup.set('id', vpypeLinesGroupId)
|
vpypeLinesGroup.set('id', vpypeLinesGroupId)
|
||||||
|
|
||||||
# inkex.utils.debug(self.svg.selection.first()) # get the first selected element. Chould be None
|
|
||||||
self.svg.selection.set(vpypeLinesGroupId)
|
|
||||||
# inkex.utils.debug(self.svg.selection.first()) # get the first selected element again to check if changing selection has worked
|
|
||||||
|
|
||||||
if self.options.output_trajectories is True:
|
if self.options.output_trajectories is True:
|
||||||
trajectories = etree.parse(output_file).getroot().xpath("//svg:g[@id='pen_up_trajectories']",namespaces=inkex.NSS)
|
trajectories = etree.parse(output_file).getroot().xpath("//svg:g[@id='pen_up_trajectories']",namespaces=inkex.NSS)
|
||||||
vpypeTrajectoriesGroup = self.document.getroot().add(inkex.Group())
|
vpypeTrajectoriesGroup = self.document.getroot().add(inkex.Group())
|
||||||
@ -310,15 +293,8 @@ class vpypetools (inkex.EffectExtension):
|
|||||||
for item in trajectories:
|
for item in trajectories:
|
||||||
for child in item.getchildren():
|
for child in item.getchildren():
|
||||||
vpypeTrajectoriesGroup.append(child)
|
vpypeTrajectoriesGroup.append(child)
|
||||||
#vpypeTrajectoriesGroup.attrib['transform'] = translation # disabled because we use PageSize with vpype now
|
|
||||||
vpypeTrajectoriesId = self.svg.get_unique_id('vpypetools-trajectories-')
|
vpypeTrajectoriesId = self.svg.get_unique_id('vpypetools-trajectories-')
|
||||||
vpypeTrajectoriesGroup.set('id', vpypeTrajectoriesId)
|
vpypeTrajectoriesGroup.set('id', vpypeTrajectoriesId)
|
||||||
self.svg.selection.add(vpypeTrajectoriesId) # we also add trajectories to selection to remove translations in following step
|
|
||||||
|
|
||||||
# we apply transformations also for new group to remove the "translate()" again # disabled because we use PageSize with vpype now
|
|
||||||
#if self.options.apply_transformations and applyTransformAvailable:
|
|
||||||
# for node in self.svg.selection:
|
|
||||||
# applytransform.ApplyTransform().recursiveFuseTransform(node)
|
|
||||||
|
|
||||||
# Delete the temporary file again because we do not need it anymore
|
# Delete the temporary file again because we do not need it anymore
|
||||||
if os.path.exists(output_file):
|
if os.path.exists(output_file):
|
||||||
|
Reference in New Issue
Block a user