Inkscape.org
Beginners' Questions Inkscape cli: select all text objects filled with a specific color and align all to bottom
  1. #1
    aborruso aborruso @aborruso

    Hi,
    I have a svg file that contains many text objects filled with the color 0070c0. This file contains also other objects.

    I would like, via CLI, to select only those text objects with that fill, and then align all to bottom, delete everything else and save to a new file.

    I think I should use verbs and action, but I can't get the result I want.

     

    Thank you

  2. #2
    barkedbut barkedbut @barkedbut

    Did you get any answer ? I would be interested...

  3. #3
    inklinea inklinea @inklinea⛰️

    Verbs are no longer used in newer versions of Inkscape, just actions. 

    There is select-by-selector however I do not believe it is possible to select a style property, just an attribute value.

    There are also no actions I know of which can get the computed style. ( colours in svg are usually inline styles but can also be attributes or classes - they resolve via a hierarchy )

    Fairly easy to do by using python - either by importing inkex (the Inkscape python module) then passing the result to a command line or by writing an extension which can be called from the command line (but does require the --batch-process option, so cannot run headless)

  4. #4
    barkedbut barkedbut @barkedbut

    Ok, thanks. Do you know where I could find some documentation about the different action commands ? I am struggling a bit with syntax.

  5. #5
    inklinea inklinea @inklinea⛰️

    To list actions: 

    inkscape --action-list 

    and just copy the output to a file.

    You will also get a list of filters / extensions which you may not want, but they are very obvious as they contain dots.

    As for syntax, you are basically following what you would do manually in the GUI, but via the command line, each command is separated by a semicolon ; and actions that take values need a colon : between the action and the value.

    There are a couple such as select-by-id which take a comma , separated list after the colon :

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

    Which is for exporting dxf files, also contains an extension to allow practising of action strings on the canvas, instead of working blind from the command line.

    Extensions>Run Command Line Action

     

     

Inkscape Inkscape.org Inkscape Forum Beginners' Questions Inkscape cli: select all text objects filled with a specific color and align all to bottom