Difference between revisions of "OpenSCAD"

From ShapeOko
Jump to: navigation, search
(Sample Files)
(Import to FreeCAD)
 
(41 intermediate revisions by the same user not shown)
Line 12: Line 12:
  
 
'''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. ”
 
'''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. ”
 
===Similar tools===
 
 
* https://github.com/thi-ng/morphogen/blob/master/src/examples.org
 
* https://libfive.com/studio/ [https://www.reddit.com/r/programming/comments/7qhjhb/studio_is_a_minimalist_gui_for_solid_modeling/]
 
 
Note also [http://www.implicitcad.org ImplicitCAD] which uses a geometric representation internally.
 
  
 
===Discussion===
 
===Discussion===
Line 26: Line 19:
 
===Interactive interface===
 
===Interactive interface===
  
 +
* https://www.blockscad3d.com/editor/#
 +
* http://graphscad.blogspot.com/
 +
* http://ultishaper.youmagine.com/app
 
* [https://github.com/martymcguire/snapscad SnapSCAD] --- an interactive/graphical interface coded in JavaScript (using [http://waterbearlang.com/ Waterbear])
 
* [https://github.com/martymcguire/snapscad SnapSCAD] --- an interactive/graphical interface coded in JavaScript (using [http://waterbearlang.com/ Waterbear])
 
* [http://forums.reprap.org/read.php?80,374436 3ddoctors.net]
 
* [http://forums.reprap.org/read.php?80,374436 3ddoctors.net]
 
* http://www.thingiverse.com/thing:3575
 
* http://www.thingiverse.com/thing:3575
 +
 +
===CLI===
 +
 +
https://hackaday.com/2017/12/10/making-rubber-stamps-with-openscad/
  
 
==Interface w/ [[Inkscape]]==
 
==Interface w/ [[Inkscape]]==
Line 37: Line 37:
 
* [http://rasterweb.net/raster/2012/11/01/inkscape-to-openscad/ Tutorial for making gears on rasterweb.net]
 
* [http://rasterweb.net/raster/2012/11/01/inkscape-to-openscad/ Tutorial for making gears on rasterweb.net]
 
* [https://www.thingiverse.com/thing:14221 Thingiverse: Inkscape OpenSCAD DXF Export]
 
* [https://www.thingiverse.com/thing:14221 Thingiverse: Inkscape OpenSCAD DXF Export]
 +
* https://www.thingiverse.com/thing:1065500
  
 
===Other vector apps===
 
===Other vector apps===
Line 56: Line 57:
 
[https://www.thingiverse.com/thing:62666 Thingiverse: STL to OpenSCAD converter]
 
[https://www.thingiverse.com/thing:62666 Thingiverse: STL to OpenSCAD converter]
  
==Import to FreeCAD==
+
==CAM options for OpenSCAD==
  
https://www.freecadweb.org/wiki/Import_OpenSCAD_code
+
===Export to DXF or SVG for [[CAM]]===
  
==Export to DXF for [[CAM]] (alternative to .stl)==
+
Rather than attempt to use 3D (stl) representation, one may instead flatten a drawing in sections using code like:
 
+
Rather than attempt to use a traditional [[CAM]] program, one may instead flatten a drawing in sections using code like:
+
  
 
<code>projection(cut=true) translate([0, 0, -3]) {...object code / reference here...};</code>
 
<code>projection(cut=true) translate([0, 0, -3]) {...object code / reference here...};</code>
Line 70: Line 69:
 
A similar technique is suggested in [http://rasterweb.net/raster/2012/07/16/openscad-to-dxf/ OpenSCAD to DXF] and a script is provided [https://github.com/mattvenn/cad/tree/master/openscad/layer_demo here].
 
A similar technique is suggested in [http://rasterweb.net/raster/2012/07/16/openscad-to-dxf/ OpenSCAD to DXF] and a script is provided [https://github.com/mattvenn/cad/tree/master/openscad/layer_demo here].
  
 +
===STL===
 +
 +
Exporting a design as a 3D STL file will allow machining it or 3D printing it using a traditional 3D CAM tool or 3D printer slicing tool within the limits of the triangular tessellation which is exported.
 +
 +
===Import to FreeCAD===
 +
 +
An OpenSCAD file may be imported into FreeCAD and CAM performed in the Path Workbench.
  
 
Using FreeCAD: https://www.reddit.com/r/openscad/comments/6hxhdc/make_2d_projections_from_openscad_models_using/dj1vuf4/
 
Using FreeCAD: https://www.reddit.com/r/openscad/comments/6hxhdc/make_2d_projections_from_openscad_models_using/dj1vuf4/
  
==CNC direct interfaces==
+
https://www.freecadweb.org/wiki/Import_OpenSCAD_code
 +
 
 +
===CNC direct interfaces===
  
 
https://github.com/peberhard/openscad/tree/carving-plugin https://github.com/peberhard/openscad-carving-plugin-doc-examples [http://forum.openscad.org/OpenSCAD-carving-feature-for-CNC-milling-machine-td14136.html]
 
https://github.com/peberhard/openscad/tree/carving-plugin https://github.com/peberhard/openscad-carving-plugin-doc-examples [http://forum.openscad.org/OpenSCAD-carving-feature-for-CNC-milling-machine-td14136.html]
Line 80: Line 88:
  
 
https://github.com/mbugert/laserscad [http://forum.openscad.org/laserscad-A-library-for-efficient-lasercutting-with-OpenSCAD-td22429.html]
 
https://github.com/mbugert/laserscad [http://forum.openscad.org/laserscad-A-library-for-efficient-lasercutting-with-OpenSCAD-td22429.html]
 +
 +
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/
 +
 +
===Parallel programming===
 +
 +
METAPOST: http://tug.org/TUGboat/tb40-2/tb125adams-3d.pdf
 +
 +
==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)  [http://forum.openscad.org/Graphscad-A-New-Nodal-editor-for-Openscad-tp20016.html] Note that it redefines primitives which may complicate use.[http://forum.openscad.org/Graphscad-A-New-Nodal-editor-for-Openscad-tp20016p26169.html]
 +
* https://github.com/studiotc/NodeGraphInterface --- Java program which will allow one to use nodes to define an OpenSCAD program [http://forum.openscad.org/Node-Graph-Interface-td26155.html] Note that instantiating the Customizer requires the explicit use of variables.[http://forum.openscad.org/Node-Graph-Interface-tp26155p26170.html]
 +
* 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 [https://youtu.be/q1Sd0Fuppuw]
 +
 +
 +
Thingiverse Customizer: http://customizer.makerbot.com/docs
  
 
==Other Support Tools==
 
==Other Support Tools==
 +
 +
Begin with: https://www.openscad.org/libraries.html
 +
 +
* https://gitlab.com/stavros/beautiscad --- code beautifier[https://www.reddit.com/r/openscad/comments/f5u71w/is_there_a_good_code_beautifier_for_openscad/]
 +
* 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/ [https://www.thingiverse.com/thing:349943 Thingiverse] [https://github.com/davidson16807/relativity.scad/wiki wiki][https://www.reddit.com/r/openscad/comments/a3pi5u/openscadlike_cad_using_python_and_jupyter/eb8q5su/]
 
* https://github.com/davidson16807/relativity.scad/ [https://www.thingiverse.com/thing:349943 Thingiverse] [https://github.com/davidson16807/relativity.scad/wiki wiki][https://www.reddit.com/r/openscad/comments/a3pi5u/openscadlike_cad_using_python_and_jupyter/eb8q5su/]
 
* http://www.cannymachines.com/entries/9/openscad_dimensioned_drawings
 
* http://www.cannymachines.com/entries/9/openscad_dimensioned_drawings
Line 131: Line 166:
 
* http://forum.openscad.org/A-small-script-to-make-a-ruler-td22313.html --- elegant parametric ruler
 
* http://forum.openscad.org/A-small-script-to-make-a-ruler-td22313.html --- elegant parametric ruler
 
* http://runeman.org/3d/egguardo/
 
* 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===
 
===Curves===
Line 136: Line 174:
 
* https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Other_Language_Features#Surface
 
* https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Other_Language_Features#Surface
 
* [https://www.thingiverse.com/thing:8483 Thingiverse: Bezier Heart in OpenScad]
 
* [https://www.thingiverse.com/thing:8483 Thingiverse: Bezier Heart in OpenScad]
* http://climberg.de/page/openscad-implementation-of-bezier-curves-of-any-degrees/
+
** https://www.thingiverse.com/thing:8931
* https://github.com/JustinSDK/dotSCAD [http://forum.openscad.org/larger-number-of-control-points-for-Bezier-td22435.html] https://openhome.cc/eGossip/OpenSCAD/BezierCurve.html
+
* http://climberg.de/page/openscad-implementation-of-bezier-curves-of-any-degrees/ https://climberg.de/post/openscad_bezier_curves
 +
* https://github.com/JustinSDK/dotSCAD [http://forum.openscad.org/larger-number-of-control-points-for-Bezier-td22435.html] 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
 
* 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 [http://forum.openscad.org/Spline-interpolation-nSpline-td15207.html]
 +
* https://www.blockscad3d.com/community/projects/68284
  
 
==Diamond Circle Square 3D Example==
 
==Diamond Circle Square 3D Example==
Line 179: Line 223:
 
* http://edutechwiki.unige.ch/en/OpenScad_beginners_tutorial
 
* 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/openSCAD-learning-resource-td3749.html]
 
* https://peak5390.wordpress.com/2013/01/08/an-introduction-to-3d-modeling-with-openscad-openscad-basics/ [http://forum.openscad.org/openSCAD-learning-resource-td3749.html]
 +
* https://openhome.cc/eGossip/OpenSCAD/
  
 
http://forum.openscad.org/How-to-make-this-parametric-code-td18352.html
 
http://forum.openscad.org/How-to-make-this-parametric-code-td18352.html
Line 185: Line 230:
  
 
https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/The_OpenSCAD_Language
 
https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/The_OpenSCAD_Language
 +
 +
https://www.thingiverse.com/groups/openscad/forums/general/topic:31166 --- discussions of how variables are treated in OpenSCAD.

Latest revision as of 19:05, 19 August 2020

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

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.)

Other vector apps

Thingiverse: Export OpenSCAD paths from Adobe Illustrator CS6 --- https://wiki.shapeoko.com/index.php/OpenSCAD#Other_vector_apps [1]

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("<filename>.stl");

Thingiverse: STL to OpenSCAD converter

CAM options for OpenSCAD

Export to DXF or SVG for CAM

Rather than attempt to use 3D (stl) representation, one may instead flatten a drawing in sections using code like:

projection(cut=true) translate([0, 0, -3]) {...object code / reference here...};

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.

STL

Exporting a design as a 3D STL file will allow machining it or 3D printing it using a traditional 3D CAM tool or 3D printer slicing tool within the limits of the triangular tessellation which is exported.

Import to FreeCAD

An OpenSCAD file may be imported into FreeCAD and CAM performed in the Path Workbench.

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

https://www.freecadweb.org/wiki/Import_OpenSCAD_code

CNC direct interfaces

https://github.com/peberhard/openscad/tree/carving-plugin https://github.com/peberhard/openscad-carving-plugin-doc-examples [2]

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

https://github.com/mbugert/laserscad [3]

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/

Parallel programming

METAPOST: http://tug.org/TUGboat/tb40-2/tb125adams-3d.pdf

Interfaces


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

Other Support Tools

Begin with: https://www.openscad.org/libraries.html

Labelling and Dimensioning of Parts

http://forum.openscad.org/Dimension-Parameter-labeling-for-part-diagrams-td15172.html

Sample Files

Curves

Diamond Circle Square 3D Example

Diamond-circle-square OpenSCAD.png


Creating a test file for this is quite straight-forward in OpenSCAD (code courtesy of Triffid Hunter[21], 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 [22].

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


Tutorials

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

References

https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/The_OpenSCAD_Language

https://www.thingiverse.com/groups/openscad/forums/general/topic:31166 --- discussions of how variables are treated in OpenSCAD.