please dont rip this site

OpenSCAD: CAD Application

A free, open source, programming language for describing physical objects. "Code Reality"

OpenSCAD is an open source CAD system that uses a programming language to describe physical objects. Although not as intuitive as other CAD programs, this does enable code reuse, combining, and libraries as well as parametric "variables" which greatly increase it's power when making complex objects.

Instead of drawing /an/ object, in OpenSCAD, you describe the idea of the object and then OpenSCAD draws any number of that sort of object for you. It can also animate or even simulate the operation of the object.

Objects are:

Primitives

cube(size ); //All units are millimeters
cube([x,y,z]); //1:1:1mm if size not specified
//actually a rectangular prism if x, y, & z are not equal

sphere(r=radius); 
// the "r=" is optional. 1mm if no radius

cylinder(r=radius, h=height); //r=1 & h=1 if not provided
cylinder(r1=top, r2=bottom, h=height);
//makes a cone if r1=0

//add ",center=true" to any object to place it at the origin.

Transformations

rotate([x,y,z]) { object }
//rotates the object the specified degrees (+/-)
//along the specified axis
translate([x,y,z]) { object } 
//moves the object from it's origin
scale(factor) { object }
//scales the object by the factor (can be a fraction)
scale([x,y,z]) { object }
//scales the object along the specified axis

Boolean Operations

difference() { object object_list }
// the later objects are subtracted from the first
union() { object_list }
// all parts of all objects are combined
intersection() { object_list }
// only the overlapping parts of all objects

Tips and Tricks

Placing a "%" before the primitive causes it to be shown as partly transparent and removed from the actual object.

%cube([x,y,z]);

This can be used to "see through" a complex part or to add a "reference" object which is not considered part of the final product, but simply shown to help coordinate the drawing.

Special Variables

All curves in OpenSCAD are approximated by straight segments. These specify the accuracy of approximations in 1 of 3 different ways:

$fa=angle; // degrees between each segment.
$fs=length; // length of each segment
$fn=number; // number of segments
// Also useful to make regular polygons. e.g. 
cylinder(r=10,h=15,$fn=6); // makes a hexagon

Parameters

One of the biggest advantages of OpenSCAD is that it can make "parametric objects" which adjust in complex ways.

These parameters look like variables in a program, but they aren't really. You can not re-assign the value*.

I=0;
translate([I*10,0,0]) cube(5);
I=I+1; // this causes an error. Instead, use:
for ( I = [0 : 5] ) { translate([I*10,0,0]) cube(5); }

Iterators

The for statements allows an object to be called many times with a range or list of parameters.

for ( parameter = [start : end] ) { object(parameter)  }
for ( parameter = [start : step : end] ) { object(parameter)  }
for ( parameter = [option[, options] ] ) { object(parameter) }

//Example to make a nut head of Size, Height.  
for (r = [-60, 0, 60])
rotate([0,0,r]) cube([Size*1.75, Size, Height], true);
	}

Conditionals

Different options can be selected using

if(condition) { objects } 
if(condition) { objects } else { objects }

Note that == is comparison, NOT =

Complex Objects: Modules

Complex objects can be grouped into modules and re-used with different parameters, very much like a subroutine:

module name(parameter[=default] [,parameters]) {objects}

Multiple parameters can be listed, and each can optionally have a default value, allowing the user to not pass it when using the module. To use the module:

name(); // invoke the module with default parameters
name(parameter=value); // override the default with a value

Code Reuse; Libraries

The real power of OpenSCAD comes from reusing code already written.

#include <complexObject.scad>
module name(ValueParameter=5, OptionParameter=34);

code libraries are available for many amazingly complex objects such as pulleys, gears, clocks, servo or motor mounts, etc...

Output

OpenSCAD can produce several types of files from the Design menu. You must Compile and Render the design (F6) before it can be exported.

  1. STL files are the industry standard for 3D objects. They are inputs to most 3D printers and are commonly shared online (along with OpenSCAD scripts) at sites like thingiverse.com.
    *OpenSCAD is open source, and like most open source programs, can be a bit… twitchy. A great free program, MeshLAB, can be used to check the STL files for errors and fix them.
  2. DFX files can be imported into AutoDesk and other popular CAD programs. SVG are popular for use on the web or for laser cutters. To save as DFX or SVG, you must create a 2D object with the projection transformation; just add it to your top level object.
    projection() object();
    Note: SVG files are made without units, which distorts the size. To correct this, edit the SVG file and add "mm" after sizes in the svg tag. E.g. <svg width="78" height="78" ... becomes <svg width="78mm" height="78mm"...
  3. PNG image files can be saved from the preview

Animation

Click View / Animate and enter FPS (Frames per Second) and Steps. E.g. 10 FPS, 100 Steps. The design will be repeatedly re-rendered, and the value in the Time field will appear in the script in the special variable $t. If "Dump…" is enabled, a new PNG file for each rendering will be saved in the same folder as the .scad file being edited. This simple program:

rotate([0,0,$t*360]) cube(); //spin a cube thru 360 degrees

will produce frames of a cube spinning. Use a program like the convert module in ImageMagick to make those frames into a video.

convert 'frame*.png' -set delay 1x24 animated.gif

By transforming parts of an object, you can make complex animations:

See also:


file: /Techref/app/OpenSCAD.htm, 8KB, , updated: 2018/11/9 16:25, local time: 2024/11/21 17:57,
TOP NEW HELP FIND: 
3.133.144.147:LOG IN

 ©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions?
Please DO link to this page! Digg it! / MAKE!

<A HREF="http://sxlist.com/techref/app/OpenSCAD.htm"> OpenSCAD: CAD Application </A>

After you find an appropriate page, you are invited to your to this massmind site! (posts will be visible only to you before review) Just type a nice message (short messages are blocked as spam) in the box and press the Post button. (HTML welcomed, but not the <A tag: Instead, use the link box to link to another page. A tutorial is available Members can login to post directly, become page editors, and be credited for their posts.


Link? Put it here: 
if you want a response, please enter your email address: 
Attn spammers: All posts are reviewed before being made visible to anyone other than the poster.
Did you find what you needed?

 

Welcome to sxlist.com!


Site supported by
sales, advertizing,
& kind contributors
just like you!

Please don't rip/copy
(here's why

Copies of the site on CD
are available at minimal cost.
 

Welcome to sxlist.com!

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  .