Inkscape.org
Beyond the Basics scripting (show/hide/export iteration)
  1. #1
    eli-damon eli-damon @eli-damon

    Hi. I have a situation where writing a script would really help, but I've never done that before, and I can't find any reference on the subject. If you know of a reference, please point me to it.

    The problem is this. I'm making a deck of game cards. I've created an Inkscape document containing all of the elements of the cards, and basically each card should contain one element from each layer. I need  to iterate through all combinations of those elements, showing the active ones, hiding the others, and exporting the result. Something like the following.

    for a from 1 to A {
        for b from 1 to B {
    ...
            hide all elements of layer 1
            show element a
            hide all elements of layer 2
            show element b
    ...
            export document
    }}...

    Thanks.
           

               
     

  2. #2
    inklinea inklinea @inklinea⛰️

    It's something which could be written as a python extension.

    https://inkscape.gitlab.io/extensions/documentation/source/index.html

    It could in theory be achieved via the command line - but more more complex.

    The language you are using looks like javascript ? 

  3. #3
    inklinea inklinea @inklinea⛰️
    *

    Here is an example extension:

    Works for 2 layer documents only

    https://gitlab.com/inklinea/layer_combinations 

    [ Appears under Extensions>Export>Layer Combinations ]

  4. #4
    eli-damon eli-damon @eli-damon

    I found several 3rd-party extensions that looked like they could do what I wanted, but I couldn't get any of them to work. Either they crash, or they don't show up in the Extensions menu at all. (I know I have to move the files into the extensions folder -- in my case, ~/.var/app/org.inkscape.Inkscape/config/inkscape/extensions -- and restart Inkscape). For example, https://github.com/fluffware/export_layer_combinations looks like pretty much exactly what I'm looking for, but it doesn't show up in the Extensions menu.

     

     

  5. #5
    inklinea inklinea @inklinea⛰️

    If you are using a Flatpak install of Inkscape, some extensions may not work. 

    If you are using Ubuntu, trying using the ppa instead.

    https://inkscape.org/release/1.2.1/gnulinux/

  6. #6
    eli-damon eli-damon @eli-damon

    Thank you for the suggestion. I am using Ubuntu, and I tried the ppa version, but that didn't help. However, I found a different extension (https://github.com/nshkurkin/inkscape-export-layer-combos) that worked for me. So I'm all set now.

Inkscape Inkscape.org Inkscape Forum Beyond the Basics scripting (show/hide/export iteration)