Difference between revisions of "OpenSCAD"

From ShapeOko
Jump to: navigation, search
(Sample Files)
(Other vector apps)
 
(26 intermediate revisions by the same user not shown)
Line 25: Line 25:
 
* [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 44: Line 48:
  
 
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
 
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
 +
 +
===Creating vectors===
 +
 +
While OpenSCAD can import DXFs and SVGs, creating vectors w/in it can be useful:
 +
 +
https://github.com/dinther/pathbuilder
  
 
==Importing .stl Files==
 
==Importing .stl Files==
Line 53: Line 63:
 
[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 67: Line 75:
 
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 83: Line 100:
  
 
https://bitbucket.org/kosme/openscad2cnc/src/master/
 
https://bitbucket.org/kosme/openscad2cnc/src/master/
 +
 +
===Parallel programming===
 +
 +
METAPOST: http://tug.org/TUGboat/tb40-2/tb125adams-3d.pdf
  
 
==Interfaces==
 
==Interfaces==
Line 89: Line 110:
 
* 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://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]
 
* 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]
 +
* https://github.com/Antyos/vscode-openscad
 +
* https://github.com/senCille/senCilleSCAD
 +
* https://github.com/nickc92/ViewSCAD
 +
* https://github.com/daid/OpenSCAD-polygon-editor
  
 
Thingiverse Customizer: http://customizer.makerbot.com/docs
 
Thingiverse Customizer: http://customizer.makerbot.com/docs
Line 96: Line 122:
 
Begin with: https://www.openscad.org/libraries.html
 
Begin with: https://www.openscad.org/libraries.html
  
 +
* https://github.com/solidboredom/constructive --- Library which provides a dialect of OpenScad syntax more suitable for complex models.
 +
* 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/JustinSDK/dotSCAD
 
* https://github.com/SquirrelCZE/CADModels/blob/master/TOOLS/hexer.scad --- tool to make objects lighter by removing hexagons
 
* https://github.com/SquirrelCZE/CADModels/blob/master/TOOLS/hexer.scad --- tool to make objects lighter by removing hexagons
Line 143: Line 171:
  
 
==Sample Files==
 
==Sample Files==
 +
 +
There are a number of repositories with especial support for OpenSCAD including Thingiverse and https://cadhub.xyz/
  
 
* [http://kitwallace.co.uk/3d/solid-index.xq Polyhedra in OpenSCAD][http://www.shapeoko.com/forum/viewtopic.php?f=6&t=7047&p=55466]
 
* [http://kitwallace.co.uk/3d/solid-index.xq Polyhedra in OpenSCAD][http://www.shapeoko.com/forum/viewtopic.php?f=6&t=7047&p=55466]
Line 151: Line 181:
 
* https://github.com/ityonemo/imsocultured/blob/master/device.scad --- tolerance for snap fit parts
 
* https://github.com/ityonemo/imsocultured/blob/master/device.scad --- tolerance for snap fit parts
 
* https://github.com/davidson16807/relativity.scad/wiki/Human-Body
 
* https://github.com/davidson16807/relativity.scad/wiki/Human-Body
 +
* https://keyholesoftware.com/2020/08/11/openscad-a-solution-for-board-game-organization/
 +
* https://github.com/moucha19/OpenSCAD-Fletching-jig
 +
* Dovetails
 +
** https://github.com/hugokernel/OpenSCAD_Dovetail
 +
** https://github.com/cfinke/OpenSCAD-Dovetails
 +
* https://github.com/HopefulLlama/JointSCAD
 +
* https://github.com/Alex9779/IKEA-Samla-Inserts
 +
* https://github.com/galaxiecruzin/boxbuilder
 +
* https://github.com/beanz/celtic-knot-scad
 +
* https://github.com/mbugert/laserscad
  
 
===Curves===
 
===Curves===
Line 196: Line 236:
  
 
==Tutorials==
 
==Tutorials==
 +
 +
* https://nostarch.com/programmingopenscad
 
* http://blog.cubehero.com/2013/11/19/know-only-10-things-to-be-dangerous-in-openscad/
 
* http://blog.cubehero.com/2013/11/19/know-only-10-things-to-be-dangerous-in-openscad/
 
* [http://hackaday.com/2013/12/11/3d-printering-making-a-thing-with-openscad/ 3D Printering: Making A Thing With OpenSCAD]
 
* [http://hackaday.com/2013/12/11/3d-printering-making-a-thing-with-openscad/ 3D Printering: Making A Thing With OpenSCAD]
Line 205: Line 247:
 
* 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/
 +
* https://learn.cadhub.xyz/docs/definitive-beginners/your-openscad-journey/
  
 
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 211: Line 255:
  
 
https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/The_OpenSCAD_Language
 
https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/The_OpenSCAD_Language
 +
 +
https://mastering-openscad.eu/buch/introduction/
 +
 +
https://www.thingiverse.com/groups/openscad/forums/general/topic:31166 --- discussions of how variables are treated in OpenSCAD.

Latest revision as of 04:52, 23 September 2021

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

Creating vectors

While OpenSCAD can import DXFs and SVGs, creating vectors w/in it can be useful:

https://github.com/dinther/pathbuilder

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

There are a number of repositories with especial support for OpenSCAD including Thingiverse and https://cadhub.xyz/

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://mastering-openscad.eu/buch/introduction/

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