3

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) – CoffeDeveloper Apr 5 '16 at 13:48
2

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.

| improve this answer | |
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.

| improve this answer | |
  • Deleting a layer in a drawing also deletes all objects on that layer, and that may not be desirable. – Andrew P. Nov 6 at 19:12
0
  1. Create a new drawing in Inkscape.
  2. Go to the Layers menu (Shift+Ctrl+L) where you will see a default layer called "Layer 1".
  3. Click on the "-" button in the menu to delete "Layer 1". Any objects drawn will now appear in root.
  4. In your original drawing containing objects on one or more layers, select the object(s) that you want to move to root. If you want to move everything to root, select all with Ctrl+A. Copy to the system clipboard with Ctrl+C.
  5. Paste the contents of the clipboard into the new layer-less drawing with Ctrl+V.

Observe that objects that previously existed on various layers now are in root in the new drawing. You may still need to align the objects relative to the drawing origin so it matches the original drawing.


I tested the foregoing using Inkscape 0.92 (Inkscape 0.92.1 r15371) running on Debian Linux 9, using a drawing with objects on multiple layers. It should work in Microsoft Windows and with later releases of Inkscape as well.

| improve this answer | |

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.