OpenSCAD

Forum user alpha mentioned this in OpenSCAD - The Programmers Solid 3D CAD Modeller, providing sample code for making a mounting plate.

OpenSCAD

Limitations
Forum user cvoinescu noted in Re: OpenSCAD - The Programmers Solid 3D CAD Modeller

OpenSCAD exports an exact STL representation of its model. No approximations are made during export. However, the internal model is created as an approximation of what's described in the source code. When you say "cylinder", for instance, OpenSCAD actually creates a prism. You can control how many faces the prism has with the $fa, $fs and $fn variables and arguments. In many 3D prints, you can see the default $fa=12 having generated a 30-sided prism, which I find annoying.

Because OpenSCAD works only with polyhedra internally (or polygons, when using it for 2D stuff), it does not need to approximate anything when exporting STL (but see note below). This is also why its DXF export is rubbish, with everything made out of segments (well, technically, the export is perfect, it's the internal model that's not appropriate for creating DXFs).

Note: Don Bright, a member of the OpenSCAD mailing list pointed out that repeating decimals are of necessity truncated, “For example, a point at (1/3, 0, 0) gets converted into (0.3333333333, 0, 0)   but of course, 0.33333333333 is an approximation of 1/3. ”

Discussion
Turning the OpenSCAD into a GUI for other scripting languages

Interactive interface

 * https://www.blockscad3d.com/editor/#
 * http://graphscad.blogspot.com/
 * http://ultishaper.youmagine.com/app
 * SnapSCAD --- an interactive/graphical interface coded in JavaScript (using Waterbear)
 * 3ddoctors.net
 * http://www.thingiverse.com/thing:3575

CLI
https://hackaday.com/2017/12/10/making-rubber-stamps-with-openscad/

Interface w/ Inkscape
Please note that there is a tool for Inkscape which will export files to a format suitable for import into OpenSCAD Inkscape gets OpenSCAD converter. (Also available here.)


 * Github source
 * Tutorial for making gears on rasterweb.net
 * Thingiverse: Inkscape OpenSCAD DXF Export
 * https://www.thingiverse.com/thing:1065500

Other vector apps
Thingiverse: Export OpenSCAD paths from Adobe Illustrator CS6 --- https://wiki.shapeoko.com/index.php/OpenSCAD#Other_vector_apps

https://github.com/anonlethal-jerk

Exporting to Carbide Create http://forum.openscad.org/OpenSCAD-dimensions-with-importing-to-Carbon-Create-td21810.html

a technique for loading the JSON from an OpenSCAD customizer and using it to generate a PDF or SVG: http://community.carbide3d.com/t/cnc-finger-joint-box/8880

Importing .stl Files
rotate([0, 0, 0]) import_stl(" .stl");

Thingiverse: STL to OpenSCAD converter

Import to FreeCAD
https://www.freecadweb.org/wiki/Import_OpenSCAD_code

Export to DXF for CAM (alternative to .stl)
Rather than attempt to use a traditional CAM program, one may instead flatten a drawing in sections using code like:

which is suggested in Hints for 2D modeling with OpenSCAD (DXF). This will allow one to export the design as .dxf(s) which may then be used in a traditional CAD/CAM workflow, or by importing into a drawing program and handling each layer by hand.

A similar technique is suggested in OpenSCAD to DXF and a script is provided here.

Using FreeCAD: https://www.reddit.com/r/openscad/comments/6hxhdc/make_2d_projections_from_openscad_models_using/dj1vuf4/

CNC direct interfaces
https://github.com/peberhard/openscad/tree/carving-plugin https://github.com/peberhard/openscad-carving-plugin-doc-examples

Discussion: http://www.mattvenn.net/2013/02/17/using-openscad-for-2d-machining/

https://github.com/mbugert/laserscad

https://hackaday.io/project/164331-rapid-3d-models-with-excel-and-openscad

https://github.com/jernst/openscad-cuts

https://bitbucket.org/kosme/openscad2cnc/src/master/

Interfaces

 * https://www.blockscad3d.com/editor/# --- allows one to save projects as XML and export as OpenSCAD code. Interface overview at: https://www.thingiverse.com/thing:2181676/
 * https://graphscad.blogspot.com/ --- Python program (available for Linux or Windows)  Note that it redefines primitives which may complicate use.
 * https://github.com/studiotc/NodeGraphInterface --- Java program which will allow one to use nodes to define an OpenSCAD program Note that instantiating the Customizer requires the explicit use of variables.
 * http://forum.openscad.org/ClikScad-create-OpenSCAD-models-without-all-the-typing-tp27474.html --- https://drive.google.com/drive/folders/1uBpil6TeYyaar_0l8Zm_17UvE-EOTza7?usp=sharing

Thingiverse Customizer: http://customizer.makerbot.com/docs

Other Support Tools
Begin with: https://www.openscad.org/libraries.html


 * https://github.com/JustinSDK/dotSCAD
 * https://github.com/SquirrelCZE/CADModels/blob/master/TOOLS/hexer.scad --- tool to make objects lighter by removing hexagons
 * https://pelablocks.org/ --- LEGO-compatible Parametric 3D Printed Blocks and Gadgets
 * https://github.com/davidson16807/relativity.scad/ Thingiverse wiki
 * http://www.cannymachines.com/entries/9/openscad_dimensioned_drawings
 * http://dkprojects.net/openscad-threads/ --- ISO standard threads
 * https://github.com/jreinhardt/BOLTS
 * https://github.com/mbugert/laserscad/
 * https://github.com/HopefulLlama/JointSCAD
 * https://bitbucket.org/kosme/openscad2cnc --- C# CLI tool for generating toolpaths for CNC machines from OpenSCAD files.
 * Embossanova --- Emboss and impress images onto a surface in OpenSCAD. Tutorial
 * PolygonRabbit --- online Flash tool to create polygons
 * AIR app to generate polygons
 * PuzzleCut OpenSCAD Library --- intended to allow one to divide a large project into smaller parts so as to print in pieces.
 * List of OpenSCAD tools (rvanee)
 * Threads
 * MScrew generator
 * http://www.thingiverse.com/thing:27183 --- OpenSCAD ISO metric thread library / functions
 * http://dkprojects.net/openscad-threads/
 * OpenScad Height Maps v0.5
 * Highly Configurable Wheel
 * Box Generator
 * Thingiverse: Customizable Box with Finger Joints --- generates a .dxf
 * List of OpenSCAD tools (drmatrix)
 * OpenSCAD surface Gimp Export Plugin
 * PGM to OpenSCAD surface
 * Thingiverse: Write.scad: http://www.thingiverse.com/thing:16193
 * http://www.thingiverse.com/thing:3575
 * MCAD OpenSCAD Parametric CAD Library
 * OpenSCAD Seamless, an online module library
 * http://aggregate.org/MAKE/TRACE2SCAD/ Trace2SCAD: Converting Images Into OpenSCAD Models
 * https://github.com/l0b0/img2scad
 * http://kyllikki.github.io/png23d/ 3d mesh generation tool
 * boat propeller customizable - OpenSCAD nSpline libary with show cases
 * http://daid.eu/~daid/3d/ --- Polygon Builder --- online tool allowing one to click and create 2D polygons which may then be extruded.
 * https://github.com/Axford/OpenSCAD_Machine_Design_Template --- https://github.com/Axford/OpenSCAD_Machine_Design_Template/blob/master/hardware/docs/VitaminCatalogue.md
 * http://www.cannymachines.com/entries/9/openscad_dimensioned_drawings
 * https://danielupshaw.com/openscad-rounded-corners/
 * Tool to generate OpenSCAD coordinates from UIUC Airfoil Coordinates Database --- http://chaaawa.com/airfoils/
 * OpenSCAD mechanical design library (omdl) --- provides open-source high-level design primitives with coherent documentation generated by Doxygen using openscad-amu
 * Thingiverse: Parametric Pulley DXF Instructable

Labelling and Dimensioning of Parts
http://forum.openscad.org/Dimension-Parameter-labeling-for-part-diagrams-td15172.html

Sample Files

 * Polyhedra in OpenSCAD
 * http://makezine.com/projects/use-math-design-mazes-openscad/
 * http://forum.openscad.org/A-small-script-to-make-a-ruler-td22313.html --- elegant parametric ruler
 * http://runeman.org/3d/egguardo/
 * http://www.tridimake.com/2014/11/how-to-use-openscad-4-children-and.html --- chained hull
 * https://github.com/ityonemo/imsocultured/blob/master/device.scad --- tolerance for snap fit parts
 * https://github.com/davidson16807/relativity.scad/wiki/Human-Body

Curves

 * https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Other_Language_Features#Surface
 * Thingiverse: Bezier Heart in OpenScad
 * https://www.thingiverse.com/thing:8931
 * http://climberg.de/page/openscad-implementation-of-bezier-curves-of-any-degrees/ https://climberg.de/post/openscad_bezier_curves
 * https://github.com/JustinSDK/dotSCAD https://openhome.cc/eGossip/OpenSCAD/BezierCurve.html https://openhome.cc/eGossip/OpenSCAD/lib-bezier_surface.html
 * http://forum.openscad.org/smooth-3-D-curves-tc7766.html
 * https://github.com/RLuckom/bezier-scad https://www.raphaelluckom.com/posts/bezier_curves.html
 * http://forum.openscad.org/Rectangle-with-one-curved-edge-td21097.html
 * http://kitwallace.tumblr.com/post/76273401911/loxodrome-in-openscad
 * http://www.thingiverse.com/thing:1208001
 * https://www.blockscad3d.com/community/projects/68284

Diamond Circle Square 3D Example


Creating a test file for this is quite straight-forward in OpenSCAD (code courtesy of Triffid Hunter, see the thread (OpenSCAD) machinist's diamond-circle-square test for a tutorial on the ShapeOko wiki for further discussion and notes on how the file shows good working practices):

$fa = 0.01; // allow $fs to work correctly $fs=0.5; // segment length of circle circumference

r_square = 50; r_circle = 45; r_diamond = 40; l_height = 3;

translate([0, 0, l_height * 0.5]) { cube([r_square,r_square,l_height], center=true); #linear_extrude(height=l_height * 1.5) circle(r=r_circle/2); cylinder(r=r_diamond/2, h=l_height * 2.5, $fn=4); }

Peter Falke provided a nice example as well.

The file may then be (Design | ) "Compile and Render"ed to prepare it for exporting as a  file which may then be processed in a CAM program for machining as described in Basic workflow 3D

Tutorials

 * http://blog.cubehero.com/2013/11/19/know-only-10-things-to-be-dangerous-in-openscad/
 * 3D Printering: Making A Thing With OpenSCAD
 * How to use Openscad --- lengthy tutorial w/ several parts covering how to use OpenSCAD "properly" so as to create parametric parts.
 * http://www.tridimake.com/2014/09/how-to-use-openscad-tricks-and-tips-to.html
 * http://www.tridimake.com/2014/09/howto-openscad-variables-modules-parametric-designs.html
 * http://www.tridimake.com/2014/11/howto-openscad-iteration-extrusion.html
 * http://www.tridimake.com/2014/11/how-to-use-openscad-4-children-and.html
 * http://edutechwiki.unige.ch/en/OpenScad_beginners_tutorial
 * https://peak5390.wordpress.com/2013/01/08/an-introduction-to-3d-modeling-with-openscad-openscad-basics/

http://forum.openscad.org/How-to-make-this-parametric-code-td18352.html