2020-11-03 16:27:09 +01:00
<?xml version="1.0" encoding="utf-8"?>
< !DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
< html xmlns = "http://www.w3.org/1999/xhtml" lang = "en" xml:lang = "en" >
< head >
2022-05-09 10:05:23 +02:00
<!-- 2022 - 05 - 09 lun. 10:04 -->
2020-11-03 16:27:09 +01:00
< meta http-equiv = "Content-Type" content = "text/html;charset=utf-8" / >
< title > Inkscape< / title >
< meta name = "author" content = "Dehaeze Thomas" / >
2022-05-09 10:05:23 +02:00
< meta name = "generator" content = "Org Mode" / >
2021-01-01 20:12:34 +01:00
< link rel = "stylesheet" type = "text/css" href = "./dist/style.css" / >
< script type = "text/javascript" src = "./dist/script.js" > < / script >
2020-11-03 16:27:09 +01:00
< / head >
< body >
< div id = "org-div-home-and-up" >
< a accesskey = "h" href = "./index.html" > UP < / a >
|
< a accesskey = "H" href = "./index.html" > HOME < / a >
2022-05-09 10:05:23 +02:00
< / div > < div id = "content" class = "content" >
2020-11-03 16:27:09 +01:00
< h1 class = "title" > Inkscape< / h1 >
2022-05-09 10:05:23 +02:00
< div id = "table-of-contents" role = "doc-toc" >
2020-11-03 16:27:09 +01:00
< h2 > Table of Contents< / h2 >
2022-05-09 10:05:23 +02:00
< div id = "text-table-of-contents" role = "doc-toc" >
2020-11-03 16:27:09 +01:00
< ul >
2022-05-09 10:05:23 +02:00
< li > < a href = "#org545a7b5" > Save Selection to SVG extension< / a >
2020-11-03 16:27:09 +01:00
< ul >
2022-05-09 10:05:23 +02:00
< li > < a href = "#orgb40377c" > < code > ink< / code > file< / a > < / li >
< li > < a href = "#orgeae997c" > < code > py< / code > file< / a > < / li >
2020-11-03 16:27:09 +01:00
< / ul >
< / li >
< / ul >
< / div >
< / div >
2022-05-09 10:05:23 +02:00
< div id = "outline-container-org545a7b5" class = "outline-2" >
< h2 id = "org545a7b5" > Save Selection to SVG extension< / h2 >
< div class = "outline-text-2" id = "text-org545a7b5" >
2020-11-03 16:27:09 +01:00
< / div >
2022-05-09 10:05:23 +02:00
< div id = "outline-container-orgb40377c" class = "outline-3" >
< h3 id = "orgb40377c" > < code > ink< / code > file< / h3 >
< div class = "outline-text-3" id = "text-orgb40377c" >
2020-11-03 16:27:09 +01:00
< div class = "org-src-container" >
< pre class = "src src-xml" > < span class = "org-nxml-processing-instruction-delimiter" > < ?< / span > < span class = "org-nxml-processing-instruction-target" > xml< / span > < span class = "org-nxml-processing-instruction-content" > version="1.0" encoding="utf-8"< / span > < span class = "org-nxml-processing-instruction-delimiter" > ?> < / span >
< span class = "org-nxml-processing-instruction-delimiter" > < ?< / span > < span class = "org-nxml-processing-instruction-target" > xml< / span > < span class = "org-nxml-processing-instruction-content" > version="1.0" encoding="UTF-8"< / span > < span class = "org-nxml-processing-instruction-delimiter" > ?> < / span >
< span class = "org-nxml-tag-delimiter" > < < / span > < span class = "org-nxml-element-local-name" > inkscape-extension< / span > < span class = "org-nxml-namespace-attribute-xmlns" > xmlns< / span > =< span class = "org-string" > "http://www.inkscape.org/namespace/inkscape/extension"< / span > < span class = "org-nxml-tag-delimiter" > > < / span >
< span class = "org-comment-delimiter" > < !-- < / span > < span class = "org-comment" > _name must have same name as .py file but capitalise it. Shows on Menu this way< / span > < span class = "org-comment-delimiter" > --> < / span >
< span class = "org-nxml-tag-delimiter" > < < / span > < span class = "org-nxml-element-local-name" > _name< / span > < span class = "org-nxml-tag-delimiter" > > < / span > < span class = "org-nxml-text" > Save Selection< / span > < span class = "org-nxml-tag-delimiter" > < < / span > < span class = "org-nxml-tag-slash" > /< / span > < span class = "org-nxml-element-local-name" > _name< / span > < span class = "org-nxml-tag-delimiter" > > < / span >
< span class = "org-comment-delimiter" > < !-- < / span > < span class = "org-comment" > id should be unique. Associates entered values with this menu < / span > < span class = "org-comment-delimiter" > --> < / span >
< span class = "org-nxml-tag-delimiter" > < < / span > < span class = "org-nxml-element-local-name" > id< / span > < span class = "org-nxml-tag-delimiter" > > < / span > < span class = "org-nxml-text" > org.inkscape.save_selection< / span > < span class = "org-nxml-tag-delimiter" > < < / span > < span class = "org-nxml-tag-slash" > /< / span > < span class = "org-nxml-element-local-name" > id< / span > < span class = "org-nxml-tag-delimiter" > > < / span >
< span class = "org-comment-delimiter" > < !-- < / span > < span class = "org-comment" > mention a dependency here and will check for existence (optional)< / span > < span class = "org-comment-delimiter" > --> < / span >
< span class = "org-nxml-tag-delimiter" > < < / span > < span class = "org-nxml-element-local-name" > dependency< / span > < span class = "org-nxml-attribute-local-name" > type< / span > =< span class = "org-string" > "executable"< / span > < span class = "org-nxml-attribute-local-name" > location< / span > =< span class = "org-string" > "inx"< / span > < span class = "org-nxml-tag-delimiter" > > < / span > < span class = "org-nxml-text" > save_selection.py< / span > < span class = "org-nxml-tag-delimiter" > < < / span > < span class = "org-nxml-tag-slash" > /< / span > < span class = "org-nxml-element-local-name" > dependency< / span > < span class = "org-nxml-tag-delimiter" > > < / span >
< span class = "org-comment-delimiter" > < !-- < / span > < span class = "org-comment" > start notebook < / span > < span class = "org-comment-delimiter" > --> < / span >
< span class = "org-nxml-tag-delimiter" > < < / span > < span class = "org-nxml-element-local-name" > param< / span > < span class = "org-nxml-attribute-local-name" > name< / span > =< span class = "org-string" > "param"< / span > < span class = "org-nxml-attribute-local-name" > type< / span > =< span class = "org-string" > "float"< / span > < span class = "org-nxml-attribute-local-name" > min< / span > =< span class = "org-string" > "0.1"< / span > < span class = "org-nxml-attribute-local-name" > max< / span > =< span class = "org-string" > "1000.0"< / span > < span class = "org-nxml-attribute-local-name" > precision< / span > =< span class = "org-string" > "5"< / span > < span class = "org-nxml-attribute-local-name" > _gui-text< / span > =< span class = "org-string" > "A floating value"< / span > < span class = "org-nxml-tag-delimiter" > > < / span > < span class = "org-nxml-text" > 1.0< / span > < span class = "org-nxml-tag-delimiter" > < < / span > < span class = "org-nxml-tag-slash" > /< / span > < span class = "org-nxml-element-local-name" > param< / span > < span class = "org-nxml-tag-delimiter" > > < / span >
< span class = "org-nxml-tag-delimiter" > < < / span > < span class = "org-nxml-element-local-name" > param< / span > < span class = "org-nxml-attribute-local-name" > name< / span > =< span class = "org-string" > "achoice"< / span > < span class = "org-nxml-attribute-local-name" > type< / span > =< span class = "org-string" > "bool"< / span > < span class = "org-nxml-attribute-local-name" > _gui-text< / span > =< span class = "org-string" > "A boolean value"< / span > < span class = "org-nxml-tag-delimiter" > > < / span > < span class = "org-nxml-text" > false< / span > < span class = "org-nxml-tag-delimiter" > < < / span > < span class = "org-nxml-tag-slash" > /< / span > < span class = "org-nxml-element-local-name" > param< / span > < span class = "org-nxml-tag-delimiter" > > < / span >
< span class = "org-nxml-tag-delimiter" > < < / span > < span class = "org-nxml-element-local-name" > effect< / span > < span class = "org-nxml-tag-delimiter" > > < / span >
< span class = "org-nxml-tag-delimiter" > < < / span > < span class = "org-nxml-element-local-name" > object-type< / span > < span class = "org-nxml-tag-delimiter" > > < / span > < span class = "org-nxml-text" > all< / span > < span class = "org-nxml-tag-delimiter" > < < / span > < span class = "org-nxml-tag-slash" > /< / span > < span class = "org-nxml-element-local-name" > object-type< / span > < span class = "org-nxml-tag-delimiter" > > < / span >
< span class = "org-nxml-tag-delimiter" > < < / span > < span class = "org-nxml-element-local-name" > effects-menu< / span > < span class = "org-nxml-tag-delimiter" > > < / span >
< span class = "org-nxml-tag-delimiter" > < < / span > < span class = "org-nxml-element-local-name" > submenu< / span > < span class = "org-nxml-attribute-local-name" > _name< / span > =< span class = "org-string" > "Save Selection"< / span > < span class = "org-nxml-tag-slash" > /< / span > < span class = "org-nxml-tag-delimiter" > > < / span >
< span class = "org-nxml-tag-delimiter" > < < / span > < span class = "org-nxml-tag-slash" > /< / span > < span class = "org-nxml-element-local-name" > effects-menu< / span > < span class = "org-nxml-tag-delimiter" > > < / span >
< span class = "org-nxml-tag-delimiter" > < < / span > < span class = "org-nxml-tag-slash" > /< / span > < span class = "org-nxml-element-local-name" > effect< / span > < span class = "org-nxml-tag-delimiter" > > < / span >
< span class = "org-comment-delimiter" > < !-- < / span > < span class = "org-comment" > py file again < / span > < span class = "org-comment-delimiter" > --> < / span >
< span class = "org-nxml-tag-delimiter" > < < / span > < span class = "org-nxml-element-local-name" > script< / span > < span class = "org-nxml-tag-delimiter" > > < / span >
< span class = "org-nxml-tag-delimiter" > < < / span > < span class = "org-nxml-element-local-name" > command< / span > < span class = "org-nxml-attribute-local-name" > location< / span > =< span class = "org-string" > "inx"< / span > < span class = "org-nxml-attribute-local-name" > interpreter< / span > =< span class = "org-string" > "python"< / span > < span class = "org-nxml-tag-delimiter" > > < / span > < span class = "org-nxml-text" > save_selection.py< / span > < span class = "org-nxml-tag-delimiter" > < < / span > < span class = "org-nxml-tag-slash" > /< / span > < span class = "org-nxml-element-local-name" > command< / span > < span class = "org-nxml-tag-delimiter" > > < / span >
< span class = "org-nxml-tag-delimiter" > < < / span > < span class = "org-nxml-tag-slash" > /< / span > < span class = "org-nxml-element-local-name" > script< / span > < span class = "org-nxml-tag-delimiter" > > < / span >
< span class = "org-nxml-tag-delimiter" > < < / span > < span class = "org-nxml-tag-slash" > /< / span > < span class = "org-nxml-element-local-name" > inkscape-extension< / span > < span class = "org-nxml-tag-delimiter" > > < / span >
< / pre >
< / div >
< / div >
< / div >
2022-05-09 10:05:23 +02:00
< div id = "outline-container-orgeae997c" class = "outline-3" >
< h3 id = "orgeae997c" > < code > py< / code > file< / h3 >
< div class = "outline-text-3" id = "text-orgeae997c" >
2020-11-03 16:27:09 +01:00
< div class = "org-src-container" >
< pre class = "src src-python" > < span class = "org-keyword" > import< / span > os
< span class = "org-keyword" > import< / span > inkex
< span class = "org-keyword" > import< / span > inkex.command
< span class = "org-keyword" > class< / span > < span class = "org-type" > SaveSelection< / span > (inkex.OutputExtension): < span class = "org-comment-delimiter" > # < / span > < span class = "org-comment" > choose a better name< / span >
< span class = "org-keyword" > def< / span > < span class = "org-function-name" > add_arguments< / span > (< span class = "org-keyword" > self< / span > , pars):
pars.add_argument(< span class = "org-string" > "--param"< / span > , < span class = "org-builtin" > type< / span > =< span class = "org-builtin" > float< / span > , dest=< span class = "org-string" > "param"< / span > , default=< span class = "org-highlight-numbers-number" > 1.0< / span > )
pars.add_argument(< span class = "org-string" > "-x"< / span > , < span class = "org-string" > "--achoice"< / span > , < span class = "org-builtin" > type< / span > =inkex.Boolean, dest=< span class = "org-string" > "achoice"< / span > , default=< span class = "org-constant" > False< / span > )
< span class = "org-keyword" > def< / span > < span class = "org-function-name" > save< / span > (< span class = "org-keyword" > self< / span > , stream):
< span class = "org-comment-delimiter" > # < / span > < span class = "org-comment" > param2 = self.options.param< / span >
< span class = "org-comment-delimiter" > # < / span > < span class = "org-comment" > choice = self.options.achoice< / span >
< span class = "org-comment-delimiter" > # < / span > < span class = "org-comment" > inkex.command.inkscape_command(self.svg, verbs=['EditInvert']);< / span >
< span class = "org-comment-delimiter" > # < / span > < span class = "org-comment" > inkex.command.inkscape_command(self.svg, verbs=['EditDelete']);< / span >
< span class = "org-comment-delimiter" > # < / span > < span class = "org-comment" > filename = os.popen('rofi -dmenu -p "Filename"')< / span >
< span class = "org-comment-delimiter" > # < / span > < span class = "org-comment" > print(filename)< / span >
< span class = "org-comment-delimiter" > # < / span > < span class = "org-comment" > inkex.debug(self.svg.selected.svg)< / span >
< span class = "org-keyword" > self< / span > .document.write(< span class = "org-keyword" > self< / span > .svg.selected)
< span class = "org-comment-delimiter" > # < / span > < span class = "org-comment" > Get selected objects< / span >
< span class = "org-comment-delimiter" > # < / span > < span class = "org-comment" > selection = self.svg.selected< / span >
< span class = "org-comment-delimiter" > # < / span > < span class = "org-comment" > selection = inkex.load_svg(< / span >
< span class = "org-comment-delimiter" > # < / span > < span class = "org-comment" > inkex.command.inkscape_command(< / span >
< span class = "org-comment-delimiter" > # < / span > < span class = "org-comment" > self.svg, verbs=['FitCanvasToDrawing']))< / span >
< span class = "org-comment-delimiter" > # < / span > < span class = "org-comment" > # Create a Canvas ovject< / span >
< span class = "org-comment-delimiter" > # < / span > < span class = "org-comment" > # Write File< / span >
< span class = "org-comment-delimiter" > # < / span > < span class = "org-comment" > # stream.write(b''.join(self.svg.selected.tostring()))< / span >
< span class = "org-comment-delimiter" > # < / span > < span class = "org-comment" > inkex.command.write_svg(selection, "/home/thomas/", "test.svg")< / span >
< span class = "org-keyword" > if< / span > < span class = "org-builtin" > __name__< / span > == < span class = "org-string" > '__main__'< / span > :
SaveSelection().run()
< / pre >
< / div >
< / div >
< / div >
< / div >
< / div >
< div id = "postamble" class = "status" >
< p class = "author" > Author: Dehaeze Thomas< / p >
2022-05-09 10:05:23 +02:00
< p class = "date" > Created: 2022-05-09 lun. 10:04< / p >
2020-11-03 16:27:09 +01:00
< / div >
< / body >
< / html >