3

I have a couple of shapes (more than 500 to be precise) that are groups of paths. Like in the image below you can only see the outer shape and any holes are grouped with the outer shape.

In order to achieve the result I want, I just ungroup the object, select Path->Difference and get the shape I want.

Left: How it looks after the import, Middle: The shapes in the group, Right: Result after ungrouping and difference

Left: How it looks after the import, Middle: The shapes in the group, Right: Result after ungrouping and difference

Is there a way to basically implement the following pseudocode in Inkscape?

FOREACH GROUP g in DOCUMENT
  ObjectPaths = UNGROUP(g)
  PATH_DIFFERENCE(ObjectPaths)

I would appreciate any solution that doesn't involve clicking over 500 times.

2
  • Hi. Welcome to GDSE. Can't you use shortcuts? Ctrl+Shift+G to ungroup, and Ctrl+- to do a Difference operation, then TAB to select next group. Sure, Inkscape can be scripted, and you can write Extensions, but that would be a programming question rather than a graphic design question.
    – Billy Kerr
    Jan 3 at 12:59
  • Thanks! However even with shortcuts doing the same thing 500 times for multiples files is no fun. I found some very helpful commandline options that solved my problem.
    – Olf
    Jan 4 at 10:10
1

Scripting documentation is inkscape is really thin. While I did not managed to solve this in Python the command line offers a possibility to solve this like this:

inkscape --verb EditSelectNext --verb SelectionUnGroup  --verb SelectionDiff \
--verb EditSelectNext --verb SelectionUnGroup  --verb SelectionDiff \
#... copy and paste the line above 500 times more ... 
--verb EditSelectNext --verb SelectionUnGroup  --verb SelectionDiff \
--verb FileSave --verb FileClose \
        --verb FileQuit file.svg

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.