Hello, I'm coming to you because I'm wondering if there is a way to manage layers by name, or by proximity between them etc... I do not know if this exists or even if others have already had the need but since I make the creation of embroidery files with Inkscape and the extension inkstitch and to pass an embroidery line or path in my layers it executes them in the order they are arranged in my groups or layers, So in order not to have my machine run to the 4 corners of my embroidery and therefore wear out the thread and lose time, I would like to find a way to classify my layers automatically. ..
Also I don't know anything about Inkstitch - so I would be wrong to advise on that subject.
However if you want to know if you can rearrange the order / stacking of layers based on criteria then yes you can.
It would be a case of getting a layer list, applying a sort criteria to that list:
svg_layers = self.svg.xpath('descendant::svg:g[@inkscape:groupmode="layer"]')
for svg_layer in svg_layers:
inkex.errormsg(svg_layer.bounding_box().width)
That would give a list of the width of each layer ( layers collapse to the elements they contain )
The layers can be moved around using commands like .append() , addnext(), addprevious() etc
I do not hide that it is complicated to explain, so I understand that what I ask is not clear, I will try to explain better with this diagram: For example : the black numbers show the order that I want in my layers, except that currently they are misplaced and so it follows the orange letters. I don't know if it's clearer :/
I think what you gave me can help, but I just don't know how to use it, I am a beginner in inkscape. If you are able to explain it to me maybe it could work for me. Thanks
Hello,
I'm coming to you because I'm wondering if there is a way to manage layers by name, or by proximity between them etc...
I do not know if this exists or even if others have already had the need but since I make the creation of embroidery files with Inkscape and the extension inkstitch and to pass an embroidery line or path in my layers it executes them in the order they are arranged in my groups or layers, So in order not to have my machine run to the 4 corners of my embroidery and therefore wear out the thread and lose time, I would like to find a way to classify my layers automatically. ..
Thanks to you and have a nice day :)
I'm not 100% sure what you want to do.
Also I don't know anything about Inkstitch - so I would be wrong to advise on that subject.
However if you want to know if you can rearrange the order / stacking of layers based on criteria then yes you can.
It would be a case of getting a layer list, applying a sort criteria to that list:
That would give a list of the width of each layer ( layers collapse to the elements they contain )
The layers can be moved around using commands like .append() , addnext(), addprevious() etc
I do not hide that it is complicated to explain, so I understand that what I ask is not clear, I will try to explain better with this diagram:
For example : the black numbers show the order that I want in my layers, except that currently they are misplaced and so it follows the orange letters. I don't know if it's clearer :/
I think what you gave me can help, but I just don't know how to use it, I am a beginner in inkscape. If you are able to explain it to me maybe it could work for me.
Thanks
I think I understand.
There is a thread on the back of the material - similar to what you have on a simple sewing machine when you lift the foot ?
So in your design, there is a long ziz-zag pattern on the reverse and that thread is wasted.
I think for sorting, it would just be the very last point of the path in each layer which determines the movement to the next layer.
Changing the layer order to put those points at the smallest travel distance between layers would save thread and movement.
So we would effectively have a stack of growing circles like a cone, each final end point sits on a bigger radius.
I think maybe ask the Inkstitch developers - as there are probably machine considerations tool.
Also path direction would need to be considered.
On second thoughts - just realised - this is a TSP (Travelling sales person) problem:
https://github.com/fillipe-gsm/python-tsp
It's a bit more complicated that I thought.
Using the above module, one can make a TSP route between points, and place each path in its own layer.
Layers then can be ordered according to the route order.
However, what we need is a path than travels through 'tunnels' - so the end point of the tunnel becomes the start point for the next leg of the route.
I have asked the author if this is possible with this module.
I've posted an initial effort as an update here https://inkscape.org/forums/extensions/objects-to-new-layer/