Inkscape.org
Creating New Extensions Selecting objects within a script.
  1. #1
    DrQt DrQt @DrQt

    I'm having trouble selecting objects from within a script.

    I'm hoping to select a set of newly created paths to hand to incadiff.py from within the script.
     

    selection = self.svg.selection
    # selection.set(id_list[0],id_list[1])
    selection.clear()
    for id in id_list:
    	selection.add(id)

    No error, but nothing seems selected in the UI.

    I'm having trouble running one extensions effect() fn from another script so I haven't been able to test if they are selected internally.

  2. #2
    inklinea inklinea @inklinea⛰️

    It's not possible to pass back selections to the main program via an extension at present.

    If you update the selection list, it will only be on the on the extension side.

    All you should need to do is add: 

    inkex.errormsg(f'\n Selected Objects: {selection_list} \n Selection Length: {len(selection_list)}')

    before and after adding to check the objects are being added.

     

     

     

  3. #3
    DrQt DrQt @DrQt

    Ah! That makes sense.  Thank you for the clarification.

    I was checking the selection, but confused as to why the GUI didn’t reflect the changes.

    Regarding running another extension, within the extension — what does it looks like to wire them up? I’ve tried instantiating the class but I haven’t been able to run fn’s from within that extensions class. 

Inkscape Inkscape.org Inkscape Forum Creating New Extensions Selecting objects within a script.