How to restore laeyrs structure and erase empty lines in XML-redactor

Post questions on how to use or achieve an effect in Inkscape.
Nike987
Posts: 9
Joined: Sat Jan 23, 2016 4:34 am

How to restore laeyrs structure and erase empty lines in XML-redactor

Postby Nike987 » Wed Oct 19, 2016 11:05 am

I have a svg file, it was created in the Adobe Illustrator 19.0.0 Software, and then exported into the *.svg.

Originally in AI Software, the file (*.ai) had a number of layers, for instance, rooms, wins, doors, etc. But after export in the Inkscape 0.91 I don't see the layers structure, only the their names. For instance, <svg: g id="rooms">.
Svg:
http://www.mediafire.com/file/7u4nb9w9l9rbos8/CS_1.svg

The second issue is empty lines in XML-Redactor.

Image

1) Is there a way to restore laeyrs structure without "copy-paste operation"?
2) Is there a way to erase empty lines in XML-redactor?

Thanks.
Last edited by prkos on Wed Oct 19, 2016 12:58 pm, edited 1 time in total.
Reason: Mediafire not very clear how to copy the image link to embed, I copied by right-clicking on the image and using the browser option, NOT by Mediafire sharing

User avatar
prkos
Posts: 1625
Joined: Tue Nov 06, 2007 8:45 am
Location: Croatia

Re: How to restore laeyrs structure and erase empty lines in XML-redactor

Postby prkos » Wed Oct 19, 2016 12:42 pm

You can add some attributes to those groups so that Inkscape could treat them as layers in Inkscape and not merely groups. Use the XML editor inside Inkscape, or simply open the SVG in a plain text editor and made the changes manually, save the file and then open in Inkscape.

Once you open the SVG with a text editor (Gedit, Notepad) or in XML editor, find the groups you want as layers, you will see something like this:

Code: Select all

<g
     id="door">


Add the inkscape:groupmode="layer" to all of them, after the ID attribute but before the closing bracket >, and add inkscape:label="Door" with the name you want for the layer. So you end up with:

Code: Select all

<g
     id="stairs" inkscape:label="Stairs" inkscape:groupmode="layer">
     
[[more code, paths etc ]]

<g
     id="door"  inkscape:label="Door" inkscape:groupmode="layer">


Search for "<g" in your text editor if it's not easy to find the groups, or search for the ID names as you're probably familiar with them (door, stairs).

After you save the file with the text editor, save as plain text, extension SVG, then open it in Inkscape and you should be able to see the layers, turn off their visibility and manipulate just as normal :)

Or in XML editor at the bottom right you have an interface for adding new attributes. Make sure you have the correct group select (in the left pane), then type the attribute name in the top one, and the attribute value in the bottom field, and press Set button. For example type "inkscape:groupmode" in the top field, and "layer" (without the quotes) in the bottom field and press, Set, then do the same for the layer label attribute.


I haven't noticed any problems with viewing code in the XML editor, no empty lines. But I'm on Linux, are you on windows? You can edit
just hand over the chocolate and nobody gets hurt

Inkscape Manual on Floss
Inkscape FAQ
very comprehensive Inkscape guide
Inkscape 0.48 Illustrator's Cookbook - 109 recipes to learn and explore Inkscape - with SVG examples to download

v1nce
Posts: 696
Joined: Wed Jan 13, 2010 4:36 am

Re: How to restore laeyrs structure and erase empty lines in XML-redactor

Postby v1nce » Wed Oct 19, 2016 9:48 pm

Do you have the svg from illustrator ? and a screenshot of what are the layers
Maybe it could be "as simple" as running it through a xslt to look for g followed by another g to turn them into a "layer"


Return to “Help with using Inkscape”