added option "keep selected" to longest cont. path extension

This commit is contained in:
leyghisbb 2021-04-14 20:54:35 +02:00
parent 23cdd26c4f
commit 817a0d35e1
2 changed files with 9 additions and 1 deletions

View File

@ -8,7 +8,8 @@
<option value="1">Allow some</option>
<option value="2">Allow none</option>
</param>
<param name="enableLog" type="bool" gui-text="Debug">false</param>
<param name="enableLog" type="bool" gui-text="Show debug log">false</param>
<param name="keepSelected" type="bool" gui-text="Keep selected elements">false</param>
<effect>
<object-type>path</object-type>
<effects-menu>

View File

@ -168,6 +168,7 @@ class OptimizePaths(inkex.GenerateExtension):
self.arg_parser.add_argument("-t", "--tolerance", type=float, default=0.1, help="the distance below which 2 nodes will be merged")
self.arg_parser.add_argument("-l", "--enableLog", type=inkex.Boolean, default=False, help="Enable logging")
self.arg_parser.add_argument("-o", "--overwriteRule", type=int, default=1, help="Options to control edge overwrite rules")
self.arg_parser.add_argument("-k", "--keepSelected", type=inkex.Boolean, default=False, help="Keep selected elements")
def parseSVG(self):
vertices = []
@ -195,6 +196,12 @@ class OptimizePaths(inkex.GenerateExtension):
else:
self.log("This extension only works with paths and currently doesn't support groups")
if self.options.keepSelected is False:
for object in objects:
if object.getparent() is not None:
#inkex.utils.debug(object.get('id'))
object.getparent().remove(object)
return (vertices, edges)
# Also computes edge weight