0

I’m searching for a solution (in Linux console) which “inverts” an SVG. It shall take an input .svg and generate output .svg with multiple shapes, each one filling a single transparent area. And vice versa - the shapes from the input file shall be converted into transparent regions.

I’ll need to feed the output .svg in a 3D CAD environment. So if the original .svg is a circle (and importing it in CAD and extruding results in a cylinder), the new, inverted .svg shall result in the CAD in a block with cylindrical hole in it.

5
  • It may be easier to use the SVG as-is and subtract the result from an arbitrary block. Cannot your CAD program do this? Commented Feb 1 at 13:00
  • It can, but I wanted to automate it as easy as possible. And I was surprised that inverting an svg is so complicated when I searched on the topic last week.
    – Ivanov
    Commented Feb 1 at 13:06
  • you'll have to create a script which parses the XML, based on this: stackoverflow.com/questions/55582885/… It depends a lot on how simple or complicated your svg is
    – 1NN
    Commented Feb 1 at 13:22
  • ``convert in.svg -channel RGB -negate /tmp/out.svg''
    – Petepf
    Commented Feb 1 at 13:37
  • @Petepf convert didn’t work for me, resulted in a corrupted file
    – Ivanov
    Commented Feb 19 at 20:36

1 Answer 1

0

You may be able to make use of the linux compatible OpenSCAD program, which supports command line use. In the example you've provided, you would create an OpenSCAD file containing the import command of your SVG file, along with a linear extrude command. Executing this from command line would result in a cylinder if the SVG file was a circle.

For the inverse, it would be a combination of a cube() command along with a difference() command containing the code which creates a cylinder.

In the GUI for OpenSCAD, this creation is trivial, but necessary. It can be performed in a simple text editor or created as a text file *.SCAD, which when called by the command line, would output what you describe in the question.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .