Presentation is loading. Please wait.

Presentation is loading. Please wait.

OpenSCAD H.C. Lilly III, Comcast Cable. What is OpenSCAD? 2D and 3D CAD Modeling Tool The CAD tool for programmers Open Source Free www.openscad.org Pronunciation:

Similar presentations


Presentation on theme: "OpenSCAD H.C. Lilly III, Comcast Cable. What is OpenSCAD? 2D and 3D CAD Modeling Tool The CAD tool for programmers Open Source Free www.openscad.org Pronunciation:"— Presentation transcript:

1 OpenSCAD H.C. Lilly III, Comcast Cable

2 What is OpenSCAD? 2D and 3D CAD Modeling Tool The CAD tool for programmers Open Source Free www.openscad.org Pronunciation: Open – ESS – CAD

3 Who Are You? Who has been on a First Robotics team before? Who has used OpenSCAD? Who has written computer programs? Who has programmed in more than one computer language? Differences between computer languages

4 Primitive Shapes cube([4, 4, 8]); sphere(r=5, $fn=100); cylinder(h=8, r1=2, r2=4, $fn=100); polyhedron( points=[[-4, 0, -4], [4, 0, -4], [0, -4, 4], [0, 4, 4]], faces=[[0, 2, 1], [0, 1, 3], [1, 2, 3], [0, 3, 2]] );

5 Test1 Code // // OpenSCAD Test 1: Primitive Shapes // translate([8, -2, 0]) cube([4, 4, 8]); translate([-10, 0, 5]) sphere(r=5, $fn=100); translate([0, 10, 0]) cylinder(h=8, r1=2, r2=4, $fn=100); translate([0, -10, 4]) polyhedron( points=[[-4, 0, -4], [4, 0, -4], [0, -4, 4], [0, 4, 4]], faces=[[0, 2, 1], [0, 1, 3], [1, 2, 3], [0, 3, 2]] );

6 Think About It How can I make my part using only these four primitives? What shapes can you make with these primitives? Notes: Functions use named parameters Make programs clear to understand, with lots of comments Dimensions are in mm Right handed coordinate system

7 Transform Operators translate([5, 0, 0]) rotate([0, 30, 0]) color([0, 0.5, 0.5]) scale([0.5, 2, 1]) mirror([0, 0, 1]) And others…

8 Test2 Code // // OpenSCAD Test 2: Transform Operators // translate([5, 0, 0]) cylinder(h=8, r1=2, r2=4, $fn=100); translate([12, 0, 0]) rotate([0, 30, 0]) cylinder(h=8, r1=2, r2=4, $fn=100); translate([25, 0, 0]) color([0, 0.5, 0.5]) cylinder(h=8, r1=2, r2=4, $fn=100); translate([35, 0, 0]) scale([0.5, 2, 1]) cylinder(h=8, r1=2, r2=4, $fn=100); translate([45, 0, 0]) mirror([0, 0, 1]) cylinder(h=8, r1=2, r2=4, $fn=100);

9 Translate and Rotate Rotation is always done around the origin The order of translate() and rotate() operations is important translate([12, 0, 0]) rotate([0, 30, 60]) color(“red”) rotate([0, 30, 60]) translate([12, 0, 0]) color(“green”)

10 Test2b Code // // OpenSCAD Test 2b: translate() and rotate() // translate([12, 0, 0]) rotate([0, 30, 60]) color("red") cylinder(h=8, r1=2, r2=4, $fn=100); rotate([0, 30, 60]) translate([12, 0, 0]) color("green") cylinder(h=8, r1=2, r2=4, $fn=100);

11 Combination Operators union() difference() intersection()

12 Test3 Code // // OpenSCAD Test 3: Combination Operators // translate([8, 8, 0]) cylinder(h=8, r1=3, r2=5, $fn=100); translate([8, -8, 0]) cylinder(h=12, r=2, $fn=100); translate([24, 0, 0]) union() { cylinder(h=8, r1=3, r2=5, $fn=100); cylinder(h=12, r=2, $fn=100); } translate([36, 0, 0]) difference() { cylinder(h=8, r1=3, r2=5, $fn=100); cylinder(h=12, r=2, $fn=100); } translate([48, 0, 0]) difference() { cylinder(h=12, r=2, $fn=100); cylinder(h=8, r1=3, r2=5, $fn=100); } translate([60, 0, 0]) intersection() { cylinder(h=8, r1=3, r2=5, $fn=100); cylinder(h=12, r=2, $fn=100); }

13 Programming Constructs Variables Arithmetic Operators: + - * / % for(a=[1:6]) { } if ((a 4)) { } else { } Relational Operators: = > Logical Operators: && || !

14 Test4 Code // // OpenSCAD Test 4: Programming Constructs // height = 4; // for(variable=[start:end]) (front row) for(a=[1:6]) { translate([((a+3)*a)+3, 0, 0]) cylinder(h=height, r=a, $fn=100); } // for(variable=[vector]) (middle row) for(a=[2, 3, 5]) { translate([((a+3)*a)+3, 17, 0]) cylinder(h=height, r=a, $fn=100); } // logical and relational operators (back row) for(a=[1:6]) { if ((a 4)) { translate([((a+3)*a)+3, 34, 0]) cylinder(h=height*3, r=a, $fn=100); } else { translate([((a+3)*a)+3, 34, 0]) cylinder(h=height, r=a, $fn=100); }

15 Putting it all Together Build a Motor Mount

16 Test5 Code, part 1 // // OpenSCAD Test 5: Motor mounting bracket // // All dimensions in mm // Motor dimensions switch = 1; motorBodyRad = 30; motorBodyLen = 60; motorCollarRad = 15; motorCollarLen = motorBodyLen + 3; motorShaftRad = 2; motorShaftLen = motorBodyLen + 20; // Bracket dimensions th = 5; mountWidth = (motorBodyRad * 2) + (th * 2); mountHeight = (motorBodyRad * 2) + th; holeRad = 4;

17 Test5 Code, part 2 // Circle precision variable cpv = 50; // Motor if (switch) { translate([th, mountWidth/2, motorBodyRad+th]) rotate([0, 90, 0]) color("turquoise") union() { cylinder(h=motorBodyLen, r=motorBodyRad, $fn=cpv); cylinder(h=motorCollarLen, r=motorCollarRad, $fn=cpv); cylinder(h=motorShaftLen, r=motorShaftRad, $fn=cpv); }

18 Test5 Code, part 3 // Mounting Bracket // Back of Bracket difference() { cube([th*2, mountWidth, mountHeight]); translate([th, th, th+motorBodyRad]) cube([th+.001, motorBodyRad*2, mountWidth]); translate([th, mountWidth/2, motorBodyRad+th]) rotate([0, 90, 0]) cylinder(h=th+.001, r=motorBodyRad, $fn=cpv); }

19 Test5 Code, part 4 // Front of Bracket difference() { translate([motorBodyLen, 0, 0]) cube([th*2, mountWidth, mountHeight]); translate([motorBodyLen-.001, th, th+motorBodyRad]) cube([th+.001, motorBodyRad*2, mountWidth]); translate([motorBodyLen-.001, mountWidth/2, motorBodyRad+th]) rotate([0, 90, 0]) cylinder(h=th+.001, r=motorBodyRad, $fn=cpv); translate([motorBodyLen+th-.001, th+motorBodyRad-motorCollarRad, th+motorBodyRad]) cube([th+.002, motorCollarRad*2, mountWidth]); translate([motorBodyLen+th-.001, mountWidth/2, motorBodyRad+th]) rotate([0, 90, 0]) cylinder(h=th+.002, r=motorCollarRad, $fn=cpv); }

20 Test5 Code, part 5 // Bottom plate cube([motorBodyLen + (th * 2), mountWidth, th]); // Ears for (trn = [ [0, -th*3, mountHeight-th], [motorBodyLen-th*2, -th*3, mountHeight-th], [0, mountWidth-th, mountHeight-th], [motorBodyLen-th*2, mountWidth-th, mountHeight-th] ]) { translate(trn) difference() { cube([th*4, th*4, th]); translate([th*2, th*2, -.001]) cylinder(h=th+.002, r=holeRad, $fn=cpv); }

21 What Else? text(); statement User Programmed Functions User Programmed Modules Trigonometric Functions Arithmetic Functions echo(); statement

22 Complete Tool Chain Calipers: Measure parts OpenSCAD: Build digital model, export as.stl MakerBot Desktop: Import.stl, create.makerbot print file MakerBot 3D Printer: Print. makerbot file in plastic


Download ppt "OpenSCAD H.C. Lilly III, Comcast Cable. What is OpenSCAD? 2D and 3D CAD Modeling Tool The CAD tool for programmers Open Source Free www.openscad.org Pronunciation:"

Similar presentations


Ads by Google