Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

change svg:g id to inkscape:label

Tags:

svg

inkscape

I made a vector graphic in Inkscape, including layers and sub-layers for further use in Processing. I named all the layers in the UI, and realized that the final SVG only creates an inkscape:label attribute with that name, but id remains generic:

<svg:g id="layer1" inkscape:label="My custom label">

I know I can manually edit the labels in the XML editor, but is there a setting somewhere to automatically use the layer name as id?

like image 211
birgit Avatar asked Nov 28 '14 05:11

birgit


1 Answers

I recently came across this question, as I was looking for the same topic. As it turned out, Inkscape (v0.92) has functions for that purpose now.

You can set IDs, and Labels in the Inkscape GUI in Object Properties menu, and they will be applied to the XML code then.

Example

Inkscape GUI

  • Draw a yellow rectangle and select it
  • Click on Object -> Object Properties...
  • In the menu set ID to yellow_rect and Label to #yellow_rect
  • Apply changes by a click on Set
  • To complete this example, repeat the steps above to create red_rect, set Label and ID
  • Eventually, group both rectanbles and set identifiers for the group as well.

enter image description here

XML Code

When I open the SVG file, Inkscape put my identifiers to the appropriate XML tags.

    <g
       id="rect_group">
      <rect
         rx="0.11797347"
         y="250.69791"
         x="5.0270834"
         height="18.785416"
         width="30.427082"
         id="yellow_rect1"
         style="fill:#f4ff00;fill-opacity:1;stroke:#000000;stroke-width:0.52916667;stroke-linejoin:round;stroke-miterlimit:3.79999995;stroke-dasharray:none;stroke-opacity:1" />
      <rect
         rx="0.11797347"
         y="258.89999"
         x="24.606249"
         height="16.933332"
         width="33.602081"
         id="red_rect1"
         style="fill:#f40000;fill-opacity:1;stroke:#000000;stroke-width:0.52916664;stroke-linejoin:round;stroke-miterlimit:3.79999995;stroke-dasharray:none;stroke-opacity:1" />
    </g>
like image 77
Kiwi Avatar answered Oct 04 '22 11:10

Kiwi