170 lines
5.7 KiB
HTML
170 lines
5.7 KiB
HTML
<!DOCTYPE html>
|
|
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
|
|
<head>
|
|
<meta charset="utf-8" />
|
|
<title>OpenSCAD</title>
|
|
</head>
|
|
<body>
|
|
<main>
|
|
<article>
|
|
<h1>OpenSCAD</h1>
|
|
<address class="h-card">
|
|
by
|
|
<a rel="author" class="u-url" href="http://changelog.ca/"><span class="p-given-name">Charles</span> <span class="p-additional-name">Iliya</span> <span class="p-family-name">Krempeaux</span></a>
|
|
</address>
|
|
<p>
|
|
<strong>OpenSCAD</strong> is an open-source computer-aided design (<abbr title="computer-aided design">CAD</abbr>) software application with its own built-in programming-language.
|
|
</p>
|
|
<p>
|
|
Unlike many other <abbr title="computer-aided design">CAD</abbr> software applications which use a <abbr title="graphical user interface">GUI</abbr> to create, edit, and manipulate objects, <strong>OpenSCAD</strong> creates, edits, and manipulates objects via a scripting programming-language.
|
|
For example:
|
|
</p>
|
|
<figure>
|
|
<pre><code>
|
|
cube([50,75,100]);
|
|
</code></pre>
|
|
</figure>
|
|
<p>
|
|
<strong>OpenSCAD</strong> scripts are usually stored in <code>.scad</code> files.
|
|
</p>
|
|
<p>
|
|
<strong>OpenSCAD</strong> includes many features similar to many imperative programming-languages; including:
|
|
</p>
|
|
<ul>
|
|
<li>variables,</li>
|
|
<li>control structures (such as if-statements and loops),</li>
|
|
<li>modules, and</li>
|
|
<li>libraries.</li>
|
|
</ul>
|
|
<p>
|
|
For those already familiar with programming-languages such as C, C++, C#, D, Dart, Go, Java, JavaScript, PHP, and others — <strong>OpenSCAD</strong> uses curly-brackets.
|
|
For example:
|
|
</p>
|
|
<figure>
|
|
<pre><code>
|
|
for (a =[x1,x2,x3]){echo(a);}
|
|
</code></pre>
|
|
</figure>
|
|
<p>
|
|
<strong>OpenSCAD</strong> provides two main methods for 3D-modeling:
|
|
</p>
|
|
<ul>
|
|
<li>creating complex object from combinations of simpler shapes, and</li>
|
|
<li>extruding 2D shapes (contained in .dxf or .svg files) into 3D shapes.</li>
|
|
</ul>
|
|
<p>
|
|
<strong>OpenSCAD</strong> is especially geared towards mechanical, rather than artistic, aspects of 3D computer-aided design.
|
|
Thus <strong>OpenSCAD</strong> can be useful when one wants to create a model that one wants to 3D-print.
|
|
</p>
|
|
<section>
|
|
<h2>Units</h2>
|
|
<p>
|
|
All dimensions in <strong>OpenSCAD</strong> are measured in (the somewhat confusingly named) "unit".
|
|
</p>
|
|
<p>
|
|
The <em>convention</em> used by a lot of people doing 3D-printing is:
|
|
</p>
|
|
<figure>
|
|
1 unit = 1 millimeter
|
|
</figure>
|
|
<p>
|
|
But <strong>OpenSCAD</strong> is in a sense unit-less.
|
|
</p>
|
|
<p>
|
|
And it is a good idea to explicitly size your model when preparing it for 3D-printing.
|
|
</p>
|
|
</section>
|
|
<section>
|
|
<h2>Cuboids</h2>
|
|
<p>
|
|
One basic 3D shape that <strong>OpenSCAD</strong> provides built-in support for is the <strong>cuboid</strong>.
|
|
</p>
|
|
<p>
|
|
To create a <strong>cuboid</strong> use the <code>cube</code> command.
|
|
For example:
|
|
</p>
|
|
<figure>
|
|
<pre><code>
|
|
cube([50,75,100]);
|
|
</code></pre>
|
|
</figure>
|
|
<p>
|
|
The parameter to the <code>cube</code> command specifies the <em>width</em>, <em>length</em>, and <em>height</em> of the <strong>cuboid</strong>.
|
|
Note that the <code>cube</code> command will put one corner of the <strong>cuboid</strong> at the origin — <code>[0,0,0]</code>.
|
|
</p>
|
|
</section>
|
|
<section>
|
|
<h2>Spheres</h2>
|
|
<p>
|
|
Another basic 3D shape that <strong>OpenSCAD</strong> provides built-in support for is the <strong>sphere</strong>.
|
|
</p>
|
|
<p>
|
|
To create a <strong>sphere</strong> use the <code>sphere</code> command.
|
|
For example:
|
|
</p>
|
|
<pre><code>
|
|
sphere(20);
|
|
</code></pre>
|
|
<p>
|
|
The paraemter to the <code>sphere<code> command specifies the <em>radius</em> of the <strong>sphere</strong>.
|
|
Note that the <code>sphere<code> command will put the center of the <strong>sphere</strong> at the origin — <code>[0,0,0]</code>.
|
|
</p>
|
|
</section>
|
|
<section>
|
|
<h2>Cylinders, Cones, and Truncated Cones</h2>
|
|
<p>
|
|
Three other basic 3D shape that <strong>OpenSCAD</strong> provides built-in support for is the <strong>cylinder</strong>, the <strong>cone</strong>, and the <strong>truncated cone</strong>.
|
|
</p>
|
|
<p>
|
|
To create a <strong>cylinder</strong>, <strong>cone</strong>, or <strong>truncated cone</strong> use the <code>cylinder</code> command.
|
|
For example, this is a <strong>cylinder</strong>:
|
|
</p>
|
|
<pre><code>
|
|
cylinder(h=50, r1=20, r2=20);
|
|
</code></pre>
|
|
<p>
|
|
Note that <code>r1</code> and <code>r2</code> have the same value.
|
|
When <code>r1</code> and <code>r2</code> have the same value, you get a <strong>cylinder</strong> (rathe than a <strong>cone</strong> or a strong>truncated cone</strong>).
|
|
</p>
|
|
<p>
|
|
And, for example, this is a <strong>cone</strong>:
|
|
</p>
|
|
<pre><code>
|
|
cylinder(h=50, r1=20, r2=0);
|
|
</code></pre>
|
|
<p>
|
|
In that example, <code>r2</code> is zero.
|
|
But having <code>r1</code> be zero (and <code>r2</code> not be zero) would also produce a <strong>cone</strong>.
|
|
</p>
|
|
<p>
|
|
And, for example, this is a <strong>truncated cone</strong>:
|
|
</p>
|
|
<pre><code>
|
|
cylinder(h=50, r1=20, r2=5);
|
|
</code></pre>
|
|
<p>
|
|
In that example, <code>r2</code> is smaller than <code>r1</code> (and neither is zero).
|
|
But having <code>r1</code> be smaller than <code>r2</code> would also be a <strong>truncated cone</strong>.
|
|
</p>
|
|
<p>
|
|
Note that the <code>cylinder<code> command will put the center of one end of the bottom circle at the origin — <code>[0,0,0]</code>.
|
|
</p>
|
|
</section>
|
|
<section>
|
|
<h2>Importing 3D Models</h2>
|
|
<p>
|
|
<strong>OpenSCAD</strong> has the ability to import shapes from other 3D applications if those shapes are stored in an <strong>.stl file</strong>.
|
|
</p>
|
|
<p>
|
|
You can import these models with the <code>import</code> command.
|
|
For example:
|
|
</p>
|
|
<code><pre>
|
|
import("3dbenchy.stl")
|
|
</pre></code>
|
|
</section>
|
|
</article>
|
|
</main>
|
|
</body>
|
|
</html>
|