#+TITLE: Inkscape #+SETUPFILE: ./setup/org-setup-file.org #+PROPERTY: header-args :comments no #+PROPERTY: header-args+ :mkdirp yes * Save Selection to SVG extension ** =ink= file #+begin_src xml :tangle ~/.config/inkscape/extensions/save_selection/save_selection.inx <_name>Save Selection org.inkscape.save_selection save_selection.py 1.0 false all #+end_src ** =py= file :PROPERTIES: :header-args: :shebang "#!/usr/bin/env python" :header-args+: :comments both :mkdirp yes :header-args+: :tangle ~/.config/inkscape/extensions/save_selection/save_selection.py :END: #+begin_src python import os import inkex import inkex.command class SaveSelection(inkex.OutputExtension): # choose a better name def add_arguments(self, pars): pars.add_argument("--param", type=float, dest="param", default=1.0) pars.add_argument("-x", "--achoice", type=inkex.Boolean, dest="achoice", default=False) def save(self, stream): # param2 = self.options.param # choice = self.options.achoice # inkex.command.inkscape_command(self.svg, verbs=['EditInvert']); # inkex.command.inkscape_command(self.svg, verbs=['EditDelete']); # filename = os.popen('rofi -dmenu -p "Filename"') # print(filename) # inkex.debug(self.svg.selected.svg) self.document.write(self.svg.selected) # Get selected objects # selection = self.svg.selected # selection = inkex.load_svg( # inkex.command.inkscape_command( # self.svg, verbs=['FitCanvasToDrawing'])) # # Create a Canvas ovject # # Write File # # stream.write(b''.join(self.svg.selected.tostring())) # inkex.command.write_svg(selection, "/home/thomas/", "test.svg") if __name__ == '__main__': SaveSelection().run() #+end_src