Convert 2D SVG to 3D SCAD models

Convert 2D SVG to 3D SCAD models

thingiverse

Edit I don't use this tool anymore, as someone said, this solution is better;https://www.thingiverse.com/thing:25036 Introduction I'm on a SCAD project for which i need objects made with various bezier curves. There are a lot of solutions around and this one is yet another one, but i like it so i share it. The principle is simple: Draw your beautiful curves with a 2D tool like the so good and free Inkscape to create SVG file, Convert path of bezier to path of lines with Inkscape, Extract the 'path' elements from the SVG and generate SCAD code with path-to-scad.js, Include the generated file and use his modules in your 3D model. Installation This is straightforward to install: Install nodejs, Check that nodejs and npm commands are in your path after installation in a console, Uncompress the archive file in any directory, this gives you 2 files and a test directory, In this directory type this command: npm update. First execution Try it on a provided test: run this command in the installation directory: nodejs path-to-scad.js -i test/sample-blobs.svg -o test/generated-blobs.scad You now have a file test/generated-blobs.scad that you can test by opening the file sample-path-to-scad.scad in you SCAD software (I use OpenSCAD). The script command line can be shown with this command: nodejs path-to-scad.js Prepare file with Inkscape There are some constraints in the SVG file. you can see one from the previous step because the SVG intentionaly contains a 'path' that cannot be imported (The green blob called 'Cloud'). Actually the script don't handle bezier curves, they must be converted to straight lines with Inkscape: The script extract path, so you need to convert objects to path, Its better to give a readable ID to the path in the object properties, This ID will be used to generate the associated module name so don't use spaces or special chars, Select the path and enter node edit mode (F2), Select all path nodes (Ctrl+a), Use the command 'Make selected segments lines', If this break too much the curves, use command 'Insert new nodes into selected segments' one or multiple times before, Do this for all the shapes you want to export and then execute path-to-scad.js. Changes This section records different versions I uploaded path-to-scad-v002.zip: New option --keep-pos to keep polygons positions as they are presented in SVG. By default polygons are centered at [0,0] path-to-scad-v003.zip: New option -v|--verbose for console logs Changed option -w|--width to -c|--columns New option -w|--watch to watch file changes and automatically regenerate Removed linear_extrude in generated polygons to let the user choose between 2D and 3D result Now uses bigdecimal for precision in relatives computations Fix: Now handle well subpaths for hollows Fix: Svg 'm' command is relative to the start of the previous subpath, not the end How I Designed This Why this script ? Before making this script, I searched a bit what was available and found 2 main approaches to get bezier curves in SCAD designs: Solution 1: SCAD bezier generator Here is an example of this solution: Public Domain OpenScad Bezier Function This has 2 main drawbacks to me: The rendering takes ages, and you get this everytime you reopen you work and generate, even if the bezier curves didn't change, The positionning of control points is very hard, you make your changes step by step, one point after another. Solution 2: DXF import Another solution was the import of SVG files. This solution was better to me because the bezier computation is made only once by inkscape. But it has some drawbacks too: SCAD cannot import svg, you must convert them to DXF after a lot of manipulations error prone (just look at this) Everytime you render the SCAD software must read and interpret the DXF. Solution 3: Convert to SCAD code This is the solution I developped with this script Of course it has drawbacks too: You must call a (very fast) script after every modification of the SVG, You must install nodejs (but this is so easy). But it has some advantages I needed: No time spent in waiting for the bezier part of the rendering, the result polygons are statics, No complicated procedures to prepare the SVG before conversion, Easy designing of the curves allowed by the powerful Inkscape tool designed for this job, No time spent in import, the product of the generator is SCAD language.

Download Model from thingiverse

With this file you will be able to print Convert 2D SVG to 3D SCAD models with your 3D printer. Click on the button and save the file on your computer to work, edit or customize your design. You can also find more 3D designs for printers on Convert 2D SVG to 3D SCAD models.