====== 2022-04-07 - importing SVG in OpenSCAD ====== that's simple -- there's [[https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/SVG_Import|import()]] call in [[wp>OpenSCAD]], that handles that, right? import("file.svg"); and we're done! except we sometimes don't... i've been using ''import()'' in the past w/o issues. yet recently, i stumbled across model made by some1 else, that failed to import correctly. when rendering, it thrown: ERROR: The given mesh is not closed! Unable to convert to CGAL_Nef_Polyhedron., location unknown. quick [[https://duckduckgo.com|duck-ducking]] and it turned out, that some programs [[https://forum.openscad.org/problem-with-SVG-import-td31295.html|make tiny holes where self-intersecting polygons are]] and this causes issues. manual edition was not an option, because model could be changed in the future and trial-and-error search for such spots would be a real pain in the back. more over [[https://github.com/openscad/openscad/issues/3430|OpenSCAD does not close open paths]] (see [[https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/SVG_Import#Open_and_closed_shapes|known limitations of import() module]] for SVG files). so how do you close these? turned out there is a nice trick to overcome this -- using [[https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Transformations#offset|offset()]] module from OpenSCAD, with some small value as a parameter: offset(0.01) import("file.svg"); ...and boom! the problem solved! offsetting closed micro gaps, forming a correct, closed shape. the nice thing is that one can use this technique on any model. in fact i now start to use it everywhere, to cut myself from this kind of issues in the future. :D