introduction to openscad · make everything parametric allows later scaling, changing and newbie...

42
Introduction to OpenSCAD Joshua M. Pearce Fulbright-Aalto University Distinguished Chair, Aalto University, Finland Department of Materials Science & Engineering and Department of Electrical & Computer Engineering, Michigan Technological University, Houghton, MI, USA

Upload: others

Post on 26-Aug-2020

14 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Introduction to OpenSCAD · Make Everything Parametric Allows later scaling, changing and newbie customization All numbers should be made variables Can use letters for simple designs

Introduction to OpenSCADJoshua M. Pearce

Fulbright-Aalto University Distinguished Chair, Aalto University, Finland

Department of Materials Science & Engineering andDepartment of Electrical & Computer Engineering,

Michigan Technological University, Houghton, MI, USA

Page 2: Introduction to OpenSCAD · Make Everything Parametric Allows later scaling, changing and newbie customization All numbers should be made variables Can use letters for simple designs

Incredibly Powerful Parametric CAD

Page 3: Introduction to OpenSCAD · Make Everything Parametric Allows later scaling, changing and newbie customization All numbers should be made variables Can use letters for simple designs

Make Everything Parametric

Allows later scaling, changing and newbie customization

All numbers should be made variables

Can use letters for simple designs // but comment

-advantages: simple equations

-disadvantage: big memory for large projects

Can use variable names describing it // box_length

-advantages: no comments, can read the code in English

-disadvantage: big messy equations

Page 4: Introduction to OpenSCAD · Make Everything Parametric Allows later scaling, changing and newbie customization All numbers should be made variables Can use letters for simple designs

Design Using Primitive Shapes and Collecting Together

Simple → Complex

Page 5: Introduction to OpenSCAD · Make Everything Parametric Allows later scaling, changing and newbie customization All numbers should be made variables Can use letters for simple designs

When Designing: Show X-Y-Z

Helps Orient Primitives

Know which way is up for printing!

Page 6: Introduction to OpenSCAD · Make Everything Parametric Allows later scaling, changing and newbie customization All numbers should be made variables Can use letters for simple designs

Primitive Objects

a=5;

b=10;

c=20;

cube([a,b,c], center=true);

sphere(a, $fn=c);

//$fn is the resolution

cylinder(h = c, r1 = b, r2 = a, center = true);

Page 7: Introduction to OpenSCAD · Make Everything Parametric Allows later scaling, changing and newbie customization All numbers should be made variables Can use letters for simple designs

Union Combining Primitives

“Try before you Buy”=%

union(){

%cube([a,b,c], center=true);

sphere(a, $fn=c);

}

Page 8: Introduction to OpenSCAD · Make Everything Parametric Allows later scaling, changing and newbie customization All numbers should be made variables Can use letters for simple designs

Difference - Subtraction

difference(){

cube([a,b,c], center=true);

sphere(a, $fn=c);

}

Page 9: Introduction to OpenSCAD · Make Everything Parametric Allows later scaling, changing and newbie customization All numbers should be made variables Can use letters for simple designs

Hull: Convex Hull of Child Nodes

hull(){

cube([a,b,c], center=true);

sphere(a, $fn=c);

}

Page 10: Introduction to OpenSCAD · Make Everything Parametric Allows later scaling, changing and newbie customization All numbers should be made variables Can use letters for simple designs

Translate: Moving Stuff Around

union(){

cube([a,b,c], center=true);

translate([0,0,b])sphere(a, $fn=c); }

Page 11: Introduction to OpenSCAD · Make Everything Parametric Allows later scaling, changing and newbie customization All numbers should be made variables Can use letters for simple designs

Rounded Corners: Minkowski

$fn=50;

minkowski() {

cube([10,10,2]);

// rounded corners

cylinder(r=2,h=2);

}

Minkowski sums allow to add every element of A to every element of B.

Page 12: Introduction to OpenSCAD · Make Everything Parametric Allows later scaling, changing and newbie customization All numbers should be made variables Can use letters for simple designs

Hand Crafting: Polyhydron

polyhedron ( points = [[0, -10, 60], [0, 10, 60], [0, 10, 0], [0, -10, 0], [60, -10, 60], [60, 10, 60]],

triangles = [[0,3,2], [0,2,1], [3,0,4], [1,2,5], [0,5,4], [0,1,5], [5,2,4], [4,2,3], ]);

Page 13: Introduction to OpenSCAD · Make Everything Parametric Allows later scaling, changing and newbie customization All numbers should be made variables Can use letters for simple designs

Intersection : Keeps All Portions That Overlap

intersection() {

cylinder (h = 4, r=1, center = true, $fn=100);

rotate ([90,0,0]) cylinder (h = 4, r=0.9, center = true, $fn=100);

}

Page 14: Introduction to OpenSCAD · Make Everything Parametric Allows later scaling, changing and newbie customization All numbers should be made variables Can use letters for simple designs

Make Each Completed Component a Module

Allows for more complex design

Clears the work space as modules are not shown unless called

Syntax:

module example(){ put your module scad here }

Call it by:

example();

Page 15: Introduction to OpenSCAD · Make Everything Parametric Allows later scaling, changing and newbie customization All numbers should be made variables Can use letters for simple designs

Modules

module example(){

union(){

cube([a,b,c], center=true);

translate([0,0,b])sphere(a, $fn=c);

}

}

example();

Page 16: Introduction to OpenSCAD · Make Everything Parametric Allows later scaling, changing and newbie customization All numbers should be made variables Can use letters for simple designs

Manipulate Your Module

rotate([45,0,0])example();

hull() {

example();

}

Add, subtract modules etc.

Page 17: Introduction to OpenSCAD · Make Everything Parametric Allows later scaling, changing and newbie customization All numbers should be made variables Can use letters for simple designs

For Repetitive Tasks Use Loops

for (i = [1:12])

{

assign (angle = i*30)

{

rotate(angle, [1,0,0])

example();

}

}

Page 18: Introduction to OpenSCAD · Make Everything Parametric Allows later scaling, changing and newbie customization All numbers should be made variables Can use letters for simple designs

Applying OpenSCAD to Science

Shadow Band Pyranometer

Page 19: Introduction to OpenSCAD · Make Everything Parametric Allows later scaling, changing and newbie customization All numbers should be made variables Can use letters for simple designs

19

Customization is Easy : OpenSCAD

Parametric Shadowband for Pyranometer

Page 20: Introduction to OpenSCAD · Make Everything Parametric Allows later scaling, changing and newbie customization All numbers should be made variables Can use letters for simple designs

Reverse Engineering Existing Equipment

Making a simple ring

> Do not design it the way it was made

> For ideal FFF printing you need a solid base on the build platform

> Design for all options for the future

Page 21: Introduction to OpenSCAD · Make Everything Parametric Allows later scaling, changing and newbie customization All numbers should be made variables Can use letters for simple designs

Ring Stand -Improved

Define VariablesDesign all ringStands not just 1

Set the resolution

Cut mass enable custom shapes : bStill print flat

Think about shapes as combinations of primitives

Page 22: Introduction to OpenSCAD · Make Everything Parametric Allows later scaling, changing and newbie customization All numbers should be made variables Can use letters for simple designs

Ring StandApplied to

FuturePrinters End:

No limits onmaterials

Page 23: Introduction to OpenSCAD · Make Everything Parametric Allows later scaling, changing and newbie customization All numbers should be made variables Can use letters for simple designs

Plate for Buckner Funnel

Page 24: Introduction to OpenSCAD · Make Everything Parametric Allows later scaling, changing and newbie customization All numbers should be made variables Can use letters for simple designs

24

Customizer and OS Customizer

https://github.com/mtu-most/most-3-d-customizer

Page 25: Introduction to OpenSCAD · Make Everything Parametric Allows later scaling, changing and newbie customization All numbers should be made variables Can use letters for simple designs

Writingfor

Customizer

Page 26: Introduction to OpenSCAD · Make Everything Parametric Allows later scaling, changing and newbie customization All numbers should be made variables Can use letters for simple designs

A Few Tricks

Scale= how big top is to bottomOffset= how far the smooth x,y

Page 27: Introduction to OpenSCAD · Make Everything Parametric Allows later scaling, changing and newbie customization All numbers should be made variables Can use letters for simple designs

Customize:Aalto Block

Page 28: Introduction to OpenSCAD · Make Everything Parametric Allows later scaling, changing and newbie customization All numbers should be made variables Can use letters for simple designs

Use Past Work

Libraries:

use <MCAD/involute_gears.scad>

include <escapementLibrary.scad>

You are using collections of

Modules written before...

Or pre-defined variables

Page 29: Introduction to OpenSCAD · Make Everything Parametric Allows later scaling, changing and newbie customization All numbers should be made variables Can use letters for simple designs

MOST Lab Librarieson Github

Do not re-invent the wheel

Stand on the Shoulders of Giants

Collection of the most useful libraries written at MTU and elsewhere

https://github.com/mtu-most/most-scad-libraries

Page 30: Introduction to OpenSCAD · Make Everything Parametric Allows later scaling, changing and newbie customization All numbers should be made variables Can use letters for simple designs

Some More Tricks to Save Time

$fn=low when designing, high when rendering

F5 for quick look

F6 only when preparing to export STL for 3D printing

Orient print --up

Break complex design into parts for printing and useJapanese wood working techniques, super glue, filament rivets, or vitamins to join them

Print prototype fast before going for pretty

Page 31: Introduction to OpenSCAD · Make Everything Parametric Allows later scaling, changing and newbie customization All numbers should be made variables Can use letters for simple designs

Cheat Sheet

http://www.openscad.org/documentation.html

Page 32: Introduction to OpenSCAD · Make Everything Parametric Allows later scaling, changing and newbie customization All numbers should be made variables Can use letters for simple designs

More information

http://www.openscad.org/

http://en.wikibooks.org/wiki/OpenSCAD_User_Manual

http://www.appropedia.org/MOST

http://reprap.org/

Page 33: Introduction to OpenSCAD · Make Everything Parametric Allows later scaling, changing and newbie customization All numbers should be made variables Can use letters for simple designs

Example: 3D Printing For Hand Tools

The finished, cement-filled corn sheller is on the right. A commercial aluminum corn sheller is on the left. The bottom sheller that was cut from a PVC pipe cap. It did not perform as well as the can.

Shelling corn is a chore done by hand in much of the rural developing world. Yet there are handy corn shellers that can save people hours of labor. DIY shellers are a big chore to make...so you can print one.

Page 34: Introduction to OpenSCAD · Make Everything Parametric Allows later scaling, changing and newbie customization All numbers should be made variables Can use letters for simple designs

Step 1: Break Complex Object Into Simple Parts

Bucket: 2 tapered cylinders

Fingers: 2 hulled cylinders

Fingers tapered in

Consider improvements:

Grips on outside – use fingers

Page 35: Introduction to OpenSCAD · Make Everything Parametric Allows later scaling, changing and newbie customization All numbers should be made variables Can use letters for simple designs

Parametric – Design ALL of the Products at Once

Step 2: Lay out variables with comments to input to Customizer

Page 36: Introduction to OpenSCAD · Make Everything Parametric Allows later scaling, changing and newbie customization All numbers should be made variables Can use letters for simple designs

Using Modules

Bucket Wall

Finger

Finger

Many Fingers

Best practices:Indent to see,comment everything$fn=100; one time

Page 37: Introduction to OpenSCAD · Make Everything Parametric Allows later scaling, changing and newbie customization All numbers should be made variables Can use letters for simple designs

Parametric Corn Sheller

Page 38: Introduction to OpenSCAD · Make Everything Parametric Allows later scaling, changing and newbie customization All numbers should be made variables Can use letters for simple designs

Customized

Anyone can make a corn sheller

perfect for them with no coding.

Page 39: Introduction to OpenSCAD · Make Everything Parametric Allows later scaling, changing and newbie customization All numbers should be made variables Can use letters for simple designs

Sheller in Action

http://www.appropedia.org/Corn_sheller

https://www.youtube.com/watch?v=DYGCtL7tED4

Page 40: Introduction to OpenSCAD · Make Everything Parametric Allows later scaling, changing and newbie customization All numbers should be made variables Can use letters for simple designs

Mini Project

• Practice your OpenSCAD coding by making simpletools from the past.

• Assignment: design and 3-D print a prototype handtool from Finland’s past

• Consider form

• Consider future printing ability for function

• How can you deconstruct a 3-D object into primatives?

Page 41: Introduction to OpenSCAD · Make Everything Parametric Allows later scaling, changing and newbie customization All numbers should be made variables Can use letters for simple designs

Some Ideas

Page 42: Introduction to OpenSCAD · Make Everything Parametric Allows later scaling, changing and newbie customization All numbers should be made variables Can use letters for simple designs