mathandy / svgpathtools

A collection of tools for manipulating and analyzing SVG Path objects and Bezier curves.
MIT License
557 stars 142 forks source link

getting paths per layer from svg #107

Open otmezger opened 4 years ago

otmezger commented 4 years ago

Hi, I have a complex SVG file generated by Inkscape. It contains several nested layers, and some of the layers contain polygons. I need to access those polygons by understanding on which layer they are.

Is there a way to access the layer information? I'm doing

paths, attributes = svgpathtools.svg2paths(svg_file_path)

but I don't see the layer information in paths or attributes.

thanks!

SebKuzminsky commented 4 years ago

The latest version of the master branch (but not the most recent release, 1.3.3) includes a new feature, svgpathtools.Document, that lets you access the DOM of the SVG XML. This lets you traverse the groups that make up Inkscape layers.

buyifadu commented 2 years ago

I can print graphic information by using ’print‘. There is a class parameter in print which I think is the presentation layer, but I don't know how to separate the path from the lay. image Like this one, I want to extract the path of the green block. Once I've extracted the path, I can fill it with layers of color. (I don't know if my description is clear. I translated it into English through software.)