Inkscape.org
Creating New Extensions Exporting multiple elements to the same svg file using --actions
  1. #1
    dr_erk dr_erk @dr_erk
    *

    Hi,

    i want to do some processing and then export selected elements as a new svg file. my plan is call subprocess from an extension with the selected ids.


    But im getting stuck at the export. I cant get it to work to add multiple elements.
    Here is what I tested:
    inkscapecom --actions="export-id:"path1;path2"; export-id-only; export-filename:action_path.svg; export-do" --active-window

     

    get this error: InkscapeApplication::parse_actions: could not find action for: path2

    Br Erik

  2. #2
    inklinea inklinea @inklinea⛰️

    It's because of the quotes and semicolons you have used.

    Actions are separated by semicolons, and object ids should be separated by commas.

    There should only be one set of double quotes with --actions=".........."

    inkscapecom --actions="export-id:path1,path2;export-id-only;export-filename:action_path.svg; export-do" drawing.svg

    Active window is not applicable unless you have Inkscape open at the time of the command line. ( I think, but I've never needed it )

  3. #3
    dr_erk dr_erk @dr_erk

    Hi and thanks for the reply:

    I get this error message when i run the script you provided:
    InkFileExportCmd::do_export_vector: Object path1,path not found in document, nothing to export.
    It seem like its looking for an ID called "path1,path2"

    I found this post:
    https://inkscape.org/forums/beyond/-shell-mode-is-it-possible-to-export-multiple-objects-by-id/

    where you discuss the multiple ids export to the same svg file. Here you have an idea to select ids, invert selection, delete selected an then save. is that the only way to do it still. and would it be possible to undo you commands after the file is saved so the original file isnt modified?

    mvh Erik

  4. #4
    dr_erk dr_erk @dr_erk

    My final goal is to automate this procedure on selected paths:

    -Apply an offset path effect,
    -bake in the effect,  
    -flip  horisontal,
    -export the selected elements only to a new svg file.
    -The original file should not be modified so all changes should be un done or not applied to this.


    What would be the best appoach to do this?

    My plan was to get the selected elements and  apply the path effect with an extension,
    and from the extension call subporcess to bake in the effect  on a copy of the original file
    and then save the elements to a new file. 

    Do you have any ideas on how to approach this?

     

  5. #5
    inklinea inklinea @inklinea⛰️

    Yes, path1, path2 - those should be ids not literally 'path1' etc.

    Have a look at this extension 

    https://gitlab.com/inklinea/dxf-14-otp

    It contains a 2nd feature that appears under Extensions>Run Command Line Action

    You don't need to look at the extension code, just use the above feature to experiment on canvas with command line actions. 

    It can save a lot of time. Let's you find an action string that works.

  6. #6
    dr_erk dr_erk @dr_erk

    Thanks!

Inkscape Inkscape.org Inkscape Forum Creating New Extensions Exporting multiple elements to the same svg file using --actions