1

As the title shows, I need to move groups to root layer in Inkscape. This is needed because I'm using a Unity plugin that allows to automatically generate a PNG atlas from a SVG file, but unluckily the only way to detect different objects is having them layed in "groups" at root layer.

A newly created Inkscape file has a default layer wich is not the root layer :/.

When I open certain SVG files I can clearly see "[Root]" layer in inkscape, but I think those files are created with another application (Illustrator) because I'm not able to reproduce the same from withint pure inkscape fresh start

  • I was able to open a file where something was already in root layer and to paste groups in there (as workaround), however this is a hack, wouldn't be better to use a specific command to do that "natively"? (like Shift+Home) – GameDeveloper Apr 5 '16 at 13:48
1

The "root" layer in Inkscape is simply any objects that are not in a layer. Layers are not part of the SVG standard; they are a special feature for groups within Inkscape, using the inkscape namespace (example: <svg:g inkscape:groupmode="layer">).

In the current version of Inkscape, there is a default layer when you create a new drawing--older versions of Inkscape didn't do this. Other SVG editing programs may or may not have their own distinct method for creating layers. The is why some SVG files may already have content in the "root" layer while others do not.

Knowing this, to move things from the root layer, you simple need to move them out of any groups that Inkscape treats as layers. You can do this with Inkscape's XML editor.

  1. Select the group you want to move.
  2. Press Ctrl+Shift+X to open the XML editor.
  3. Do one of the following:
    • Click and drag the group to the root <svg> element. (just after the <svg:metadata> is a good place)
    • If the group you want to move to the "root" later is a layer in Inkscape, select the inkscape:groupmode attribute for the group, and in the XML Editor's toolbar click the Delete Attribute button.

Example

If my svg file looks like this:

<svg:svg>
    <svg:g inkscape:groupmode="layer">
         <svg:rect ... />
    </svg:g>
</svg>

Then I want to modify it to be like either of the following:

<svg:svg>
    <svg:rect ... />
    <svg:g inkscape:groupmode="layer">
    </svg:g>
</svg>

or

<svg:svg>
    <svg:g>
         <svg:rect ... />
    </svg:g>
</svg>

Both of these will move my drawing to the root layer. The second example will retain the original layer as a group.

0

After asking in InkscapeForum

I found I just need to remove all layers, this is not a perfect solution (what If I need some layer existing for some reason?) but at least a feasible and easy solution.

To remove a layer I need to open layer window Layer->layers and hit the minus - button in that window.

I'll accept the answer that allows to moving groups from any layer to the root layer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.