script for union of all paths of the same color

Post questions on how to use or achieve an effect in Inkscape.
jutzin
Posts: 3
Joined: Mon Sep 14, 2015 4:30 pm

script for union of all paths of the same color

Postby jutzin » Mon Sep 14, 2015 4:44 pm

Hello all,

I would like to find an automatic solution for the following workflow.

  • open/import file (eg. eps format)
    • select all paths of color x (ctr+f in xml editor for first hex-color string)
    • ctrl++ to union selection
    • repeat for all remaining colors
  • export to svg

or, if you will,

Code: Select all

open or import file (eg. eps format);
for (all colors in drawing)
{
    select all paths of the current color;
    perform union on selected paths;
}
export drawing;

I suppose there should be a solution along the lines of

Code: Select all

inkscape -f input.eps --verb=EditDeselect --select=allPathsOfSameColors --verb=SelectionUnion --export-simple-svg

However, I have no clue how to go about selecting all paths of the same color or how to iterate over all colors.

Any help or pointers would be very much appreciated.

User avatar
Maestral
Posts: 982
Joined: Sat Aug 27, 2011 7:10 am

Re: script for union of all paths of the same color

Postby Maestral » Mon Sep 14, 2015 11:25 pm

Before some more precise replies...

Check in XML editor (Shift+Ctrl+X) about path/stroke and colour atributes in Inkscape, where options from Find dialog (Ctrl+F) might offer a base for further development of script.
:tool_zoom: <<< click! - but, those with a cheaper tickets should go this way >>> :!:

jutzin
Posts: 3
Joined: Mon Sep 14, 2015 4:30 pm

Re: script for union of all paths of the same color

Postby jutzin » Thu Sep 17, 2015 6:00 pm

Thank you, Maestral, for your reply.

That what you proposed is exactly what I am doing manually (shift+ctr+x for xml editor --> ctr+f for find --> search in properties --> find #00ffff (or some other hex string, this selects all paths which contain this hex color --> ctrl++ (union all selected paths).

I would like to get an idea whether this can be done via a script or a one liner from the command line.

User avatar
Maestral
Posts: 982
Joined: Sat Aug 27, 2011 7:10 am

Re: script for union of all paths of the same color

Postby Maestral » Thu Sep 17, 2015 7:26 pm

Although it might look like I`m advertizing them, AutoIt is a very handy and still free tool for customizing Win.
:tool_zoom: <<< click! - but, those with a cheaper tickets should go this way >>> :!:

User avatar
brynn
Posts: 10309
Joined: Wed Sep 26, 2007 4:34 pm
Location: western USA
Contact:

Re: script for union of all paths of the same color

Postby brynn » Fri Sep 18, 2015 11:13 am

As much as I dislike the mailing list type of forum, that is how Inkscape developers, and advanced users appear to like to communicate. So I'm sure you could reach some advanced users (who could help with script writing) via the user mailing list (and even a lot of developers) https://inkscape.org/en/community/mailing-lists/. So just in case you don't get the right kind of help here, I'm sure you'll get it there :D

~suv
Posts: 2272
Joined: Sun May 10, 2009 2:07 am

Re: script for union of all paths of the same color

Postby ~suv » Fri Sep 18, 2015 4:55 pm

jutzin wrote:I would like to get an idea whether this can be done (…) a one liner from the command line.

No, it cannot be done with a one liner using inkscape on the command line (you'd have to use verbs for this; verbs are used internally (e.g. for the menu items and toolbar buttons), and are not optimal for non-interactive use cases via command line because they take no arguments).

jutzin
Posts: 3
Joined: Mon Sep 14, 2015 4:30 pm

Re: script for union of all paths of the same color

Postby jutzin » Wed Sep 23, 2015 12:54 am

Thanks guys, I will take your advice and a) check with the mailing list and b) try to automatize with auto-it (which is great, no argument there, but not a proper solution for a production environment).


Return to “Help with using Inkscape”