Hello,
I have an inkscape file with many symbols on it. Some of them are shapes.
When I select one or more shapes and I use the Extension "Color" - "Color replace" I can change the color without problems.
What I need is this:
- The shapes have unique Id's/names (A01, A02, S01, S02, ...) in a own Layer
- I have a text-file which contains Ids and Colors (A01 0000FF) of the shapes in separate lines
- I want an extension which reads the textfile and changes the color of the read id to the (in the textfile) defined color.
How can I do this?
Kind regards,
bernie70
Change Color by Id / Name
Change Color by Id / Name
Last edited by bernie70 on Wed May 08, 2013 5:34 pm, edited 1 time in total.
Re: Change Color by Id / Name
Hi.
One way to accomplish this would be through a script.
Python is my language of choice, but you could use a utility like grep (linux-unix) - wingrep (Win) or any language capable of reading and writing text-files.
Can you supply example files for us to work from?
We might be able to "hack together" a solution.
RGDS
Ragnar
One way to accomplish this would be through a script.
Python is my language of choice, but you could use a utility like grep (linux-unix) - wingrep (Win) or any language capable of reading and writing text-files.
Can you supply example files for us to work from?
We might be able to "hack together" a solution.
RGDS
Ragnar
Good Luck!
( ͡° ͜ʖ ͡°)
RGDS
Ragnar
( ͡° ͜ʖ ͡°)
RGDS
Ragnar
Re: Change Color by Id / Name
Hi Ragnar,
thank you for the answer. I created a sample testfile to show you what I want.
In the example.svg there are the shapes like in my original-svg. The colors can always be different (yellow, red, blue). In the example.txt there are the colors to which the shapes should be changed with the extension.
Kind regards,
bernie70
thank you for the answer. I created a sample testfile to show you what I want.
In the example.svg there are the shapes like in my original-svg. The colors can always be different (yellow, red, blue). In the example.txt there are the colors to which the shapes should be changed with the extension.
Kind regards,
bernie70
- Attachments
-
- example.zip
- Zip-File contains example.svg and example.txt
- (1.43 KiB) Downloaded 346 times
Re: Change Color by Id / Name
We might be able to "hack together" a solution.
"We..."
Welcome to the forum, bernie70
Basics - Help menu > Tutorials
Manual - Inkscape: Guide to a Vector Drawing Program
Inkscape Community - Inkscape FAQ - Gallery
Inkscape for Cutting Design
Manual - Inkscape: Guide to a Vector Drawing Program
Inkscape Community - Inkscape FAQ - Gallery
Inkscape for Cutting Design
-
- Posts: 2
- Joined: Fri Mar 22, 2013 6:03 pm
Re: Change Color by Id / Name
Hello
You could try this enclosure; tested on debian.
Voilà!
You could try this enclosure; tested on debian.
Voilà!
- Attachments
-
- readfile.zip
- Read File
- (1003 Bytes) Downloaded 401 times
Re: Change Color by Id / Name
Hi Bernie70
Another approach - not as elegant as atommisant's;
To use:
- save the attached file to a temporary place
- unzip and then place the two unpacked files in your "Local" extension directory - mine is on Win7; "C:\Users\Ragnar\AppData\Roaming\inkscape\extensions"
- restart Inkscape;
- find extension under; Extensions - Bernie70
Extension will ask for input data file name (File with ID and corresponding fill color);
Extension will only change selected items. (Select before running extension )
Extension removes stroke - like "atommisant's" extension - chime back if this is not wanted.
Extension will most likely not be very useful for anyone else than Bernie70 -
____ ( Unless you got similar color changing tasks based on a CSV (comma separated value) file. )
- brynn;
Thanks atommisant - (Just what the doctor ordered ! At the right time! )
Yes "we" - the users of the forum!
Zip file - tested on Win7;
Good Luck
RGDS
Ragnar
Another approach - not as elegant as atommisant's;
To use:
- save the attached file to a temporary place
- unzip and then place the two unpacked files in your "Local" extension directory - mine is on Win7; "C:\Users\Ragnar\AppData\Roaming\inkscape\extensions"
- restart Inkscape;
- find extension under; Extensions - Bernie70
Extension will ask for input data file name (File with ID and corresponding fill color);
Extension will only change selected items. (Select before running extension )
Extension removes stroke - like "atommisant's" extension - chime back if this is not wanted.
Extension will most likely not be very useful for anyone else than Bernie70 -
____ ( Unless you got similar color changing tasks based on a CSV (comma separated value) file. )
- brynn;
"We..."
Thanks atommisant - (Just what the doctor ordered ! At the right time! )
Yes "we" - the users of the forum!
Zip file - tested on Win7;
Good Luck
RGDS
Ragnar
Good Luck!
( ͡° ͜ʖ ͡°)
RGDS
Ragnar
( ͡° ͜ʖ ͡°)
RGDS
Ragnar
Re: Change Color by Id / Name
Hi atomissant, hi ragstian,
thank you for your answers.
I tried your extensions and both are working fine. Thank you very much for the solutions. Now I have to decide, which version I will use
Kind regards,
bernie70
thank you for your answers.
I tried your extensions and both are working fine. Thank you very much for the solutions. Now I have to decide, which version I will use
Kind regards,
bernie70
Re: Change Color by Id / Name
Hi atomissant, hi ragstian,
now I have seen, that the size (width and heigth) of the modified nodes is modified a little bit after executing the extension.
Is it possible to leave the size untouched or how can I change the size of the node with the extension?
Kind regards,
bernie70
now I have seen, that the size (width and heigth) of the modified nodes is modified a little bit after executing the extension.
Is it possible to leave the size untouched or how can I change the size of the node with the extension?
Kind regards,
bernie70
Re: Change Color by Id / Name
Hi,
I could solve the problem myself with with node.set(*width', ...) and node.set('height', ...)
Greetings,
bernie70
I could solve the problem myself with with node.set(*width', ...) and node.set('height', ...)
Greetings,
bernie70
Re: Change Color by Id / Name
You can use Python can be termed as best choice and don't forget to use a utility like grep (linux-unix) - wingrep (Win) or any language.