Inkscape.org
Beginners' Questions Command Line Text Search Find Replace
  1. #1
    123pauln123 123pauln123 @123pauln123

    Hello, I cannot find any command line examples/documentation to search for an object.  

    Did this used to be supported with the verb dialogueFInd ...?

    I can specify objects by ID to manipulate from the CLI - but these identifiers change depending on the PDF content.  

    Using Win10 Inkscape 1.2 

    Any suggestions much appreciated.  

  2. #2
    inklinea inklinea @inklinea⛰️

    There are a few select actions:

    If you type inkscape --action-list | findstr select-

    It should list the following:

    select-all          :  Select all; options: 'all' (every object including groups), 'layers', 'no-layers' (top level objects in layers), 'groups' (all groups including layers), 'no-groups' (all objects other than groups and layers, default)
    select-by-class     :  Select by class
    select-by-element   :  Select by SVG element (e.g. 'rect')
    select-by-id        :  Select by ID
    select-by-selector  :  Select by CSS selector
    select-clear        :  Clear selection
    select-invert       :  Invert selection; options: 'all', 'layers', 'no-layers', 'groups', 'no-groups' (default)
    select-list         :  Print a list of objects in current selection
    select-original     :  Select the object to which the selected clone is linked
    unselect-by-id      :  Deselect by ID

    Here's a more complex example.

    https://inkscape.org/forums/tutorials/command-line-dbus-select-namespaced-attributes/

     

  3. #3
    123pauln123 123pauln123 @123pauln123

    Thank you.  I have used the info you provided to test with select-by-element and select-by-selector.  So far, I have only been successful in selecting all text in the file.

    Is it possible to either:

    Refine the selection to all items containing a specific word/phrase (same as using the GUI Find dialogue) OR

    Select say, 3 items following inkscape:label="Page 6" thereby referencing the XML order.

    Kind regards. 

  4. #4
    inklinea inklinea @inklinea⛰️

    No I don't think it's possible without using scripting to get a comma separated id list.

    That would mean either python or something like xmlstarlet.

    Scripting would allow for the use of XPath instead of just css.

    I think css only allows for wildcard attribute values, but not wildcard attribute names.

    The best you can do with the command line is select elements then you can set attributes or style properties using object-set-property or object-set-attribute

  5. #5
    123pauln123 123pauln123 @123pauln123

    You are correct.  

    Today i used https://inkscape.org/~Moini/★nextgenerator-replace-export from https://gitlab.com/Moini/nextgenerator to achieve my goal by:

    changing line 80 of next_gen.py to search_string = key 

    this meant that when it searches the relevant .csv it would find in column headings everything I wanted to delete & replace with "" (effectively deleting all items specified) 

     I would commend to the inkscape community, this brilliant python script which effectively enables find/replace within inkscape.   

    Let me know your thoughts.  Kind regards.  

Inkscape Inkscape.org Inkscape Forum Beginners' Questions Command Line Text Search Find Replace