OpenSCAD

From ShapeOko
Jump to: navigation, search

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

OpenSCAD

Contents

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

Similar tools

Note also ImplicitCAD which uses a geometric representation internally.

Interactive interface

Interface w/ Inkscape

Please note that there is a tool for Inkscape which will export files to a format suitable for import: Inkscape gets OpenSCAD converter.

Alternative to Exporting .stl to use for CAM

Rather than attempt to use a traditional CAM program, 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 manually process the .dxfs either by using a traditional CAD/CAM workflow, or 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.

Other Support Tools

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[1], 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 [2].

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

Personal tools
Namespaces
Variants
Actions
About
Additional Build Information
Using Your Machine
Software
Upgrades
Additional Resources
ShapeOko 1 Build Instructions
wiki
Toolbox