This extension will re-layer your selected items or the whole document according to their color (stroke or fill). Each style will be put onto it's own layer. This way you can devide elements by their colors with ease. It does some basic-only handling of gradient styles.
See also https://inkscape.org/~MarioVoigt/%E2%98%85remove-empty-groups for useful cleaning extension.
Notes:
- includes "Apply Transformations" extension
thanks, would it be possible to add the stroke style option?
eg. to group the objects in layer by line thinkness.
hi, i updated this and added filters for hue, saturation and luminance, as well as hex value and opacities =)
hi, on linux, when I try "fill colors" I get this error:
Traceback (most recent call last):
File "fablabchemnitz_styles_to_layers.py", line 210, in <module>
LayerGroup().run()
File "/usr/share/inkscape/extensions/inkex/base.py", line 123, in run
self.save_raw(self.effect())
File "fablabchemnitz_styles_to_layers.py", line 114, in effect
if fill_value != "none": neutral_value = colorsort(fill_value)
File "fablabchemnitz_styles_to_layers.py", line 53, in colorsort
return float(int(stroke_value[1:], 16))
ValueError: invalid literal for int() with base 16: 'rl(#meshgradient161)'
hi,
i hadded handling of gradient elements. shouldnt crash from now on. regards =)
thanks Mario,
now it works but with the option "empty groups" enabled I receive this error:
usage: fablabchemnitz_styles_to_layers.py [-h] [--output OUTPUT] [--id IDS]
[--selected-nodes SELECTED_NODES]
[INPUT_FILE]
fablabchemnitz_styles_to_layers.py: error: unrecognized arguments: --separateby=fill --parsecolor=hexval --subdividethreshold=1 --decimals=1 --cleanup=true
Calling 'Remove Empty Groups' extension failed.
that error is okay. You can put https://inkscape.org/~MarioVoigt/%E2%98%85remove-empty-groups into your extensions dir to make it work. it just works like some shortcut :-) i uploaded newer files which make it clearer
I had already the remove-empty-groups extension, anyway I've reinstalled them both but not avail:
"Calling 'Remove Empty Groups' extension failed.
Maybe the extension is not installed. You can download it from official InkScape Gallery."
I can use the remove-empty-groups extension, maybe there is an error in the way you recall it?
did you put the py/inx files at the same directory level or did you put them into separate folders? Have no other idea what could be the reason for it for the moment. I will check it out on my windows computer. Maybe there is some difference
yes they're booth in the "extensions" folder
hi. i uploaded a new zip containing all neccesary files. i guess some old faulty string was contained inside the python file. i did some renaming and maybe forgot to sync this change to the other extension. should work for you now (but remove the old ones please)
hey, it's becoming a long chat...
now it's working but I found a problem if there is text in the drawing, some letters will disappear.
I wanted to upload my test but it's not possible, my file is a word with the letters split in different objects and with different color fill/stroke, after applying the extension the letters are gone.
thanks in advance!
hey,
this was easy to fix. I commited an update to https://gitea.fablabchemnitz.de/MarioVoigt/mightyscape-1.X/raw/commit/b80abd0d85255988e543864353584e52dc379dfc/extensions/fablabchemnitz/styles_to_layers.py
will upload soon in InkScape gallery as well.
by the way i stumbled upon some kind of similar extension from Evil Mad Scientist some days ago. You could try out too. have a look at a
https://github.com/evil-mad/wcb-ink/blob/master/extensions/wcb_color.py
https://github.com/evil-mad/wcb-ink/blob/master/extensions/wcb_color.inx
Hello Mario,
thank you for developing this extension, it is really useful!
However, I do get this error after running it (Inkscape 1.0):
Traceback (most recent call last):
File "styles_to_layers.py", line 239, in <module>
StylesToLayers().run()
File "C:\Program Files\Inkscape 1.0\share\inkscape\extensions\inkex\base.py", line 140, in run
self.save_raw(self.effect())
File "styles_to_layers.py", line 160, in effect
layerNode[0].append(layerNode[2]) #append element to created layer
File "src/lxml/etree.pyx", line 825, in lxml.etree._Element.append
File "src/lxml/apihelpers.pxi", line 1341, in lxml.etree._appendChild
ValueError: cannot append parent to itself
Can you help me? Thanks,
Marco
Hi Marco,
if you like you can send me your file or some similar thing which causes that issue to mario.voigt@stadtfabrikanten.org - then i can have a look into it what's happening and how to fix. Without an example it will be harder to find the issue.
regards, Mario :-)