Inkscape.org
Beyond the Basics Command line features missing or undocumented
  1. #1
    MetalSutton MetalSutton @MetalSutton

    I am working with the command line on inkscape and it can almost do everything I would like it to. The sections I have highlighted in red are what I am having trouble with

    inkscape --actions="select-all;path-combine;object-set-attribute:"stroke-width", 1.2mm;object-set-attribute:"stroke-linejoin","round";object-set-attribute:"stroke-linecap","round";object-stroke-to-path" -g dxf/bs.dxf

    First of all, the select-all action seems to select all items on all layers. What I would like it to do is replicate a "Ctrl+A" so it selects all items on the current (or specific) layer. How can I get around this? Do I have to select some criteria with another method?

    Secondly, the action object-stroke-to-path only works when you are in Node editing mode (N), and I do not see an option to enter path node editing. 

  2. #2
    inklinea inklinea @inklinea⛰️

    Inkscape --actions-list > actions.txt

    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)

    A couple of useful actions:

    query-all    :  Query 'x', 'y', 'width', and 'height'

    This will list all drawable items in the document, including layers (groups)

    select-list   :  Print a list of objects in current selection

    This will let you see what you have managed to select - so you are not guessing.

    If you want to select the contents of a specified layer you can try using select-by-selector

    https://www.w3schools.com/cssref/css_selectors.asp

    So if you find your layer name using --query-all

    inkscape --actions="select-by-selector:#LayerTest*;select-list" ./drawing.svg

    Should get all objects in that layer ( will also return the group and all children )

    inkscape --actions="select-by-selector:#LayerTest>*;select-list" ./drawing.svg

    Should just get the top level children inside that layer.

    I'm not sure about Node editing mode from the command line ? 

  3. #3
    MetalSutton MetalSutton @MetalSutton

    Awesome thanks! That worked. It's a bit annoying that I cannot reference the actual string name of the layer in the file and that I have to use something like g234, because inkscape still uses the correct layer name so it must know what the layer is called somehow. I guess it might just be a caveat of how the dxf importer works I suppose. Means I cannot batch convert and will have to look up the group code each time. Not a major, just annoying. 

     

  4. #4
    MetalSutton MetalSutton @MetalSutton
    **

    Also it's not that I really want to edit any nodes, but it seems that when using inkscape, even in GUI mode, that "stroke to path" does not work with just the path selected. Could this be a bug?

  5. #5
    inklinea inklinea @inklinea⛰️

    I've not had any problems with object-stroke-to-path In Inkscape 1.2 ( I have not tried in 1.2.1 )

    inkscape --actions="select-all;object-stroke-to-path;export-do" ./strokes.svg 

    You may be aware that Inkscape svgs ( not plain svgs ) contain extra tags / attributes / properties either in the inkscape: or sodipodi: namespace

    It's a simple way of  extending functionality whilst maintaining compatibility with other non Inkscape svg readers.

    <g
         inkscape:label="Layer 1"
         inkscape:groupmode="layer"
         id="layer1">

    This is a layer in Inkscape, notice that label and groupmode are in the Inkscape namespace, they are transparent to other svg readers such as browsers.

    Also when you are looking at the Layer pane in Inkscape you are looking at the label, not the svg id.

    They may very well be the same in some cases. If you go into edit>XML Editor you can see the actual ids.

    Ids have to be unique, Labels do not.

    It's relatively simple with a python loop to write the id for each object to the label so they are the same. 

  6. #6
    MetalSutton MetalSutton @MetalSutton

    Ah cool Thanks. So if doing a query on the file only allows us to see the ID data of the file, then is that all we have to pick from when doing a selection search? 

    The problem I have is that the DXF importer gives different IDs each import. I would like to search by "inkscape:label" if possible.  

    I found this: https://stackoverflow.com/questions/15110866/select-svg-element-by-inkskapelabel-attribute  , but might not help. 
     

  7. #7
    inklinea inklinea @inklinea⛰️

    post a sample svg converted file

Inkscape Inkscape.org Inkscape Forum Beyond the Basics Command line features missing or undocumented