Inkscape.org
Using Inkscape with Other Programs python subprocess to run Inkscape extension (idraw2)
  1. #1
    curiouscat03 curiouscat03 @curiouscat03

    Hi,

    I am trying to write a python script using suprocess to run an Inkscape extension idraw2 which is used with an idraw pen plotter. The extension can be found here https://idrawpenplotter.com/downloads. Is this possible?

    Thanks in advance.

  2. #2
    inklinea inklinea @inklinea⛰️

    Do you want an extension to launch another extension via Inkscape ? This is possible - but would just launch the 2nd extension as if the user has opened it.

    Since the idraw2 (which seems to be based on Evil Mad Scientist Axisdraw), uses Inkscape .inx files to create the extension gui - then no menus will appear unless Inkscape itself launches the extension directory.

    You would have to integrate the python modules into your own extension to be useful.

  3. #3
    curiouscat03 curiouscat03 @curiouscat03

    hm I am not sure I understand entirely.

    I would like to run the idraw2 extension without having to open up the gui. I would like to create a python script that will launch Inkscape (w/o the gui) and then access the idraw2 extension that will then execute the plot feature under the idraw2 extension.

    I know that I can use python subprocess like here https://stackoverflow.com/questions/50915483/python-subprocess-run-not-running-inkscape-pdf-to-svg so I was wondering if I can run the idraw2 extension and call their plot feature in this way. 

  4. #4
    inklinea inklinea @inklinea⛰️

    If you are using python subprocess, you can run more or less anything. A shell script, executable or an Inkscape command line.

    In fact inkex (the extension system api)  has https://inkscape.gitlab.io/extensions/documentation/source/inkex.command.html

    However you are still limited by what the Inkscape command line can achieve. It cannot pass parameters to an extension.

     

  5. #5
    curiouscat03 curiouscat03 @curiouscat03

    Yes, you explained that well in my other thread.

    So is there a way to run the extension without the gui? Does writing an extension to run the idraw extension achieve this?

  6. #6
    inklinea inklinea @inklinea⛰️

    You would have to write something to use the modules directly.

    ----------------------------------------------

    The only other option is a horrible hack which I don't recommend. Unless it's just for your own personal use. 

    After you exit Inkscape cleanly, there will be an entry in preferences.xml for the extension.

    You can manually parse and edit it with python before running the command line. The gui must not be open during this process. 

    I only use it for myself if I want to iterate an extension value. I used it for example with the guilloche extension to repeat shifted patterns. 

  7. #7
    curiouscat03 curiouscat03 @curiouscat03

    Is there documentation or a tutorial on how to write something to use the modules directly?

    The second option, I don't think would work for me since I would like others to also run my program.

  8. #8
    inklinea inklinea @inklinea⛰️

    I have done it once before, but it's a the very edge of my python abilities. 

    Maybe ask in https://chat.inkscape.org/channel/inkscape_extensions

     

Inkscape Inkscape.org Inkscape Forum Using Inkscape with Other Programs python subprocess to run Inkscape extension (idraw2)