no way to compare when less than two revisions

Differences

This shows you the differences between two versions of the page.


blog:2022:04:07:2022-04-07_-_importing_svg_in_openscad [2022/04/07 11:26] (current) – created basz
Line 1: Line 1:
 +====== 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?
 +
 +<code c>
 +import("file.svg");
 +</code>
 +
 +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:
 +
 +<code c>
 +offset(0.01)
 +  import("file.svg");
 +</code>
 +
 +...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
blog/2022/04/07/2022-04-07_-_importing_svg_in_openscad.txt · Last modified: 2022/04/07 11:26 by basz
Back to top
Valid CSS Driven by DokuWiki Recent changes RSS feed Valid XHTML 1.0