inkscape:groupmode="layer": why is this required ?

Discuss SVG code, accessible via the XML Editor.
User avatar
Hibou57
Posts: 29
Joined: Sat Jan 17, 2009 10:57 pm
Contact:

inkscape:groupmode="layer": why is this required ?

Postby Hibou57 » Tue Nov 08, 2011 8:51 am

Hi all graphic designers,

It seems Inkscape does not directly recognize SVG layers, and requires all svg:g elements hold this attributes:

Code: Select all

inkscape:groupmode="layer"

Otherwise Inkscape will not handle as layer, any layer not holding this attribute-value pair.

What's the rational for this ?

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

Re: inkscape:groupmode="layer": why is this required ?

Postby prkos » Tue Nov 08, 2011 9:35 am

IIRC layers aren't part of the SVG specification, they are only present in Inkscape where they are implemented as special types of groups (groups are part of the specs), with the attribute you found.
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

User avatar
Hibou57
Posts: 29
Joined: Sat Jan 17, 2009 10:57 pm
Contact:

Re: inkscape:groupmode="layer": why is this required ?

Postby Hibou57 » Tue Nov 08, 2011 10:00 am

I suspected this, due to the name svg:g, but erroneously believed svg:g was probably a layer in SVG designer's mind.

I am just seasoned with Inkscape, so I may not, but I wish a future day I will try to design a tiny plugin which automatically ensure all group elements has a groupmode attribute.

Thanks for the clear answer :)

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

Re: inkscape:groupmode="layer": why is this required ?

Postby prkos » Tue Nov 08, 2011 10:37 am

That might be nice :) Although not all cases need the group to be a layer, but it would be nice if we could pick groups and turn them into layers or have other ways of handling them.
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

User avatar
Hibou57
Posts: 29
Joined: Sat Jan 17, 2009 10:57 pm
Contact:

Re: inkscape:groupmode="layer": why is this required ?

Postby Hibou57 » Tue Nov 08, 2011 11:39 am

prkos wrote:Although not all cases need the group to be a layer

You are obviously right. May be an heuristic would be to treat each apart, top‑level groups and nested‑groups (groups inside of a parent group). First candidate to become layers would better be top‑level ones. But you are also right, the idea of extracting any group to make it a layer, could be of interest to someones too.

User avatar
LiquidAsh
Posts: 71
Joined: Fri Apr 22, 2011 11:35 pm
Contact:

Re: inkscape:groupmode="layer": why is this required ?

Postby LiquidAsh » Thu Nov 17, 2011 2:47 am

I've implemented this functionality of converting groups into layers and back in a more complex extension I'm building. If anyone's interested, I'll be happy to share the code specific to this conversion. It basically works as follows:

Code: Select all

if a group is selected:
  change that group's id to <oldId>_from_<oldParentId>
  add the layer-specific groupmode attribute
  remove group from current location in heirarchy, and add it to the root node
if nothing is selected, and the current layer's id contains the sequence "_from_"
  remove the groupmode attribute change the current layer's id back to <oldId>
  remove this node from the root
  find parent using <oldParentId>, and add this (former layer) group to it

User avatar
RobA
Posts: 335
Joined: Fri Aug 10, 2007 1:22 am

Re: inkscape:groupmode="layer": why is this required ?

Postby RobA » Thu Nov 17, 2011 4:28 am

LiquidAsh wrote:I've implemented this functionality of converting groups into layers and back in a more complex extension I'm building. If anyone's interested, I'll be happy to share the code specific to this conversion. It basically works as follows:

Code: Select all

if a group is selected:
  change that group's id to <oldId>_from_<oldParentId>
  add the layer-specific groupmode attribute
  remove group from current location in heirarchy, and add it to the root node
if nothing is selected, and the current layer's id contains the sequence "_from_"
  remove the groupmode attribute change the current layer's id back to <oldId>
  remove this node from the root
  find parent using <oldParentId>, and add this (former layer) group to it


I'd suggest it keep the new layer right where it was (as inkscape does support nested layers) rather than moving it to root...

-Rob A>

User avatar
LiquidAsh
Posts: 71
Joined: Fri Apr 22, 2011 11:35 pm
Contact:

Re: inkscape:groupmode="layer": why is this required ?

Postby LiquidAsh » Sat Nov 19, 2011 4:12 am

RobA wrote:I'd suggest it keep the new layer right where it was (as inkscape does support nested layers) rather than moving it to root...


Interesting... I didn't realize that Inkscape supports nested layers. I wonder how layers nested in non-layer groups are treated(?). I might have to play around with this a bit when I find some time.

Edit: all parent groups are treated as layers when a nested group has the layermode=layer attribute setting.


Return to “SVG / XML Code”