Inkscape.org
Creating New Extensions HELP! Problem of running extension !!!
  1. #1
    PlsHelp PlsHelp @PlsHelp
    *

    Hi everyone, I have a urgent question to ask and confirm.

    If I have two functions as below:

    import inkex

    class Afunct(inkex.EffectExtension):

            something..... 

    class Bfunct(inkex.EffectExtension):

           something.....

    if __name__ == '__main__':

         if a > b: #For example

            Afunct().run()

            Bfunct().run()

     

    Why the program will only run Afunct().run() but ignore Bfunct().run()?

    Hope my question is clear to understand or else I will the make it more details.

    Thank you

  2. #2
    inklinea inklinea @inklinea⛰️

    I have not seen an extension which contains multiple EffectExtension classes.

    Generally there is only one. 

    Types of extension classes can be seen here : https://inkscape.gitlab.io/extensions/documentation/source/inkex.extensions.html

    The current list of bundled extensions are here:

    https://gitlab.com/inkscape/extensions/

    Have a look at the code. I think you will not find any with multiple Inkscape extension classes.

    I think the general approach is to write defs  and only have one class.

  3. #3
    Gavin Johnson Gavin Johnson @snow6oy

    I had a use-case where the user first generates an SVG and then later has an option to modify it. I considered doing this with two classes. Similar to the above, I tried running either Generate or EffectExtension depending on user options. However, in the end I went for EffectExtension because it seems to be a superset of what Generate can do.

Inkscape Inkscape.org Inkscape Forum Creating New Extensions HELP! Problem of running extension !!!