SVG export with layers

Discussion forum for contributors and developers who are using the QCAD version 3 ECMAScript development platform or the C++ plugin interface or who are otherwise looking to contribute to QCAD (translations, documentation, etc).

Moderator: andrew

SVG export with layers

Postby dave5 » Thu Apr 19, 2012 6:16 pm

Is there a way of programmatically exporting to SVG and retaining layer data?
dave5
Newbie Member
 
Posts: 4
Joined: Thu Apr 19, 2012 6:15 pm

Re: SVG export with layers

Postby andrew » Thu Apr 19, 2012 8:12 pm

No, layer information is currently not transferred to SVG. The reason is that SVG does not have support for layers.

SVG has groups of course, but groups are a concept that is orthogonal to layers. For example a block in QCAD is exported as a group in SVG. Since two blocks may both contain entities on the same two different layers, the concept of groups alone is not sufficient to implement both layers and blocks but only either one of the two concepts.

Inkscape emulates layers somehow, but I didn't look into that yet. They extend SVG with several Inkscape specific tags and arguments. It's possible that QCAD will support that in the future which would of course mean that layers would be supported for Inkscape only.

Would that be useful for you? Can you give some information about your use case?
User avatar
andrew
Site Admin
 
Posts: 2544
Joined: Fri Mar 30, 2007 6:07 am

Re: SVG export with layers

Postby hungerburg » Fri Apr 20, 2012 11:21 am

I did a quick check with inkscape: when I group two objects, that are in different so called "layers", the group will then become part of the upper "layer". "layer" information of the objects themselves is lost by grouping them. This is an irreversible action. Exploding the group will put all the members into the "layer" of the group. This can be easily watched in the XML-Editor window of inkscape: "layers" are indeed groups with special attributs, but members do not reference these "layers" by special attributes at all.

As a consequence, as of Inkscape 0.48.2 r9819, there is NO way of transparently/reversibly mapping *two distinct hierarchies* like blocks and layers of QCAD+DXF to inkscape+SVG.
User avatar
hungerburg
Senior Member
 
Posts: 125
Joined: Fri May 28, 2010 7:35 pm

Re: SVG export with layers

Postby andrew » Fri Apr 20, 2012 11:32 am

hungerburg: thanks for the research. This is bad news. I have to admit that I've expected something different that could be supported.

In this case, the concept of layers in CAD is indeed not transferable to SVG / Inkscape.
User avatar
andrew
Site Admin
 
Posts: 2544
Joined: Fri Mar 30, 2007 6:07 am

Re: SVG export with layers

Postby hungerburg » Fri Apr 20, 2012 12:12 pm

Sorry for bringing bad news. I now read http://wiki.inkscape.org/wiki/index.php/DocumentLayers and there also is no indication that this is a known deficiency of inkscapes interpretation of what SVG can be taught to. Instead it says there, that Adobe Illustrator uses the same concepts, and the adobe online reference at least seems to point the same way (http://help.adobe.com/en_US/illustrator ... 635fa.html statement on transparency). If I find the time, I will look, if Illustrator can keep group and layer information separately and reversibly serialize as svg.
User avatar
hungerburg
Senior Member
 
Posts: 125
Joined: Fri May 28, 2010 7:35 pm

Re: SVG export with layers

Postby hungerburg » Wed May 02, 2012 10:55 am

I found the time to look at how Adobe Illustrator handles grouping and layering. It also has a tree view of the drawing's entities, similar to Inkscape's XML view. And just the same, groups are nodes below layers. Grouping of entities on different layers will put the group into one layer. Exploding this group later will put the members in this layer. So I did not bother to look how layers are serialized in SVG, because already the in-memory model seems not ready to support the DXF paradigm of two separate trees for groups and layers.
User avatar
hungerburg
Senior Member
 
Posts: 125
Joined: Fri May 28, 2010 7:35 pm

Re: SVG export with layers

Postby andrew » Wed May 02, 2012 10:58 am

OK, thanks for sharing this information.
User avatar
andrew
Site Admin
 
Posts: 2544
Joined: Fri Mar 30, 2007 6:07 am

Re: SVG export with layers

Postby dave5 » Tue May 08, 2012 1:58 am

No stress... my use case was to use named layers to drive other business processes.
dave5
Newbie Member
 
Posts: 4
Joined: Thu Apr 19, 2012 6:15 pm


Return to QCAD 3 Developers and Contributors

Who is online

Users browsing this forum: No registered users and 1 guest