Oddbean new post about | logout
 @d6d660e8 Depending on what your goal is, gerbolyze's svg-flatten utility might help you. svg-flatten renders SVGs into Gerber (G-code) files in a visually precise way. Here's a link: https://github.com/jaseg/gerbolyze/tree/main/svg-flatten 
 @d6d660e8 One other issue with converting SVG files into other formats is that SVG has some raster primitives such as masks and filters. A file that uses these would be almost impossible to convert in a way that the user expects. svg-flatten for instance doesn't support them, but has support for clip paths, which it does by pushing converted polygons through clipper. 
 @7f73a7d1 Thanks for the input. I guess it's reasonable to expect the user to provide a primitive SVG with only paths. This is what pretty much all CAD software does that I have used. (non-path elements are just ignored). So shapely does not know about Bezier curves? Can it only handle straight lines? If so, then an arbitrary precision needs to be used, right. Would be fine for me if there's Python tooling for that. 
 @d6d660e8 I'm not sure about all of shapely, but at least offsetting and boolean operations AFAIK only work with polygons made with straight line segments. Shapely IIRC just wraps libgeos here. I'm not aware of any implementation of polygon clipping or offsetting that supports beziers. I know one that supports circular arcs, but converting beziers to those isn't easy either. 
 @7f73a7d1 Then off I go to find a Python tool to chop am SVG's Bezier curves into line segments 🚶 
 @d6d660e8 For your SVG input, I can recommend the usvg utility from the resvg project. It's an SVG normalizer that takes any spec-compliant SVG as an input,and produces an SVG output that only uses a small subset of the spec, making it much easier to handle. That's how svg-flatten works.