Advertisement
Advertisement

More Related Content

Advertisement
Advertisement

3D Design with OpenSCAD

  1. 3D Design with OpenSCAD Vicky Somma vicky@tgaw.com @TGAW http://tgaw.wordpress.com http://www.Shapeways.com/shops/tgaw This presentation is on SlideShare at: http://www.slideshare.net/VickyTGAW/3d-design-with-openscad
  2. OpenSCAD – Download • Free 3D Modeling Software • Available for Windows, Linux, and MacOS • Good at “clean” models (taking some of worry out of the process– you can be oblivious to “non-manifold” and “bad face normals”) • Because it’s instruction-base, it’s easy to visualize measurements and come back and tweak it http://www.openscad.org/downloads.html
  3. OpenSCAD – User Manual Don’t Be Intimidated! You Don’t Have to Memorize the Syntax! Online User Manual https://en.wikibooks.org/wiki/OpenSCAD_User_Manual Quick Cheat Sheet http://www.openscad.org/cheatsheet/
  4. OpenSCAD – Anatomy of User Interface Text Editor – Where we put our instructions (“code”) Viewing Area – Your handiwork! Renders of the model. Console – Technical information about what’s going on (progress on rendering, any error messages)
  5. OpenSCAD – Text Editor Commands Icons to create new files, save, undo, redo, indent, preview, render, and most importantly for 3D Printing-- export to STL format.
  6. OpenSCAD – Text Editor to Viewing Area To see how your work looks, you can: • Use Preview ( ) or Render ( ) icons • Use the Design->Preview or Design->Render menu options • Or the fastest option - use F5 for Preview and F6 for Render
  7. OpenSCAD – Viewing Area Commands Commands for Viewing, Rendering, Zooming In, Changing Views, Turning On or Off Axis and Measurements Display, Showing Edges Versus Faces
  8. OpenSCAD – The Mouse & the Viewing Area • Left clicking and dragging allows you to rotate your view • Right clicking and dragging pans the view • Scroll wheel allows you to zoom in and out
  9. OpenSCAD – Syntax Common Themes • ; - The end of an instruction (ie make a cube;) • // - A comment or label– for your purposes– will be ignored by the viewing area • { } - Grouping of commands • [x,y,z] – “Vectors” (Coordinates, 3D sizes) Reference: https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/General
  10. OpenSCAD – Primitive Objects – Cube cube([10,10,10]); cube([10,20,30]);cube([x, y, z]); Draws 3D boxes Not necessarily perfect cubes – you can make rectangles with it as well. Reference: https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Primitive_Solids#cube
  11. OpenSCAD – Primitive Objects – Cylinder cylinder(r=10,h=22); cylinder(r1=10,r2=3,h=22); cylinder(r=x,h=z); cylinder(r1=x,r2=y,h=z); Draws cylinders – and not necessarily perfect cylinders Reference: https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Primitive_Solids#cylinder
  12. OpenSCAD – Primitive Objects – Cylinder cylinder(r1=9, r2=0, h=9, $fn=4); $fn parameter controls # of fragments Increase– you can make really smooth objects Decrease it– you can make Triangles, Pentagons, Pyramids, etc. cylinder(r=9,$fn=3);cylinder(r=9,h=10,$fn=300); Reference: https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Primitive_Solids#cylinder
  13. OpenSCAD – Primitive Objects – Sphere sphere(d=22); sphere(d=22, $fn=100);sphere(d=x); Draws spheres – and you can control resolution $fn parameter controls how smooth it looks Reference: https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Primitive_Solids#sphere
  14. OpenSCAD – Primitive Objects You can build a lot out of standard shapes
  15. OpenSCAD – Primitive Objects You can build a lot out of these standard shapes- “Bipedal Mech” by Mathew Ridge http://shpws.me/GQX5
  16. OpenSCAD – 2D Objects - Text text("TGAW"); Text(“x”); Draws text. Text is great for customizing your models, engraving, and embossing. Reference: https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Text
  17. OpenSCAD – 2D Objects - Text Text(“x”, Font=“Font Name”); Since OpenSCAD is installed on your machine, you can use any font already on your machine! text("TGAW", font="Rockwell Extra Bold"); text("TGAW", font="Old English Text MT"); text("TGAW", font="Wingdings"); Reference: https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Text
  18. OpenSCAD – 2D Objects - Polygons polygon([[-24,0],[0,0],[0,32] ,[-16,32],[-15,28],[-13,24] ,[-12,20],[-12,15],[-13,10] ,[-15,6],[-19,3]]); Polygon([x1,y1],[x2,y2],etc); You specify the points to make customized shapes (which you can then extrude to 3D if needed) Reference: https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/2D_Primitives#polygon
  19. OpenSCAD – 2D Objects - Polygons Need visual help making Polygons? http://daid.eu/~daid/3d A graphical interface that builds your polygon code for you.
  20. OpenSCAD – 2D to 3D linear_extrude(height = 10) polygon([[-24,0],[0,0],[0,32],[-16,32] ,[-15,28],[-13,24],[-12,20],[-12,15] ,[-13,10],[-15,6],[-19,3]]); Linear_Extrude(height=x) Makes your 2D object (circle, square, polygon) 3D It can even twist the object as it grows up NO SEMICOLON AFTER IT (It’s not the end of the statement– we have to tell it what to extrude) Reference: https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/2D_to_3D_Extrusion#Linear_Extrude
  21. OpenSCAD – 2D to 3D linear_extrude(height = 20, center = false , $fn = 100, twist=30) text("TGAW"); Linear_Extrude(height=x, twist=degrees) Works on text and you can do fancy stuff like twisting Reference: https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/2D_to_3D_Extrusion#Linear_Extrude
  22. OpenSCAD – 2D to 3D rotate_extrude(convexity = 10, $fn=300) polygon([[-24,0],[0,0],[0,32],[-16,32],[-15,28] ,[13,24],[-12,20],[-12,15],[-13,10] ,[-15,6],[-19,3]]); Rotate_Extrude() Your 2D object (circle, square, polygon) is rotated around to make a 3D object (like a cross section) NO SEMICOLON AFTER IT It’s not the end of the statement-- we need to tell it what to extrude. Reference: https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/2D_to_3D_Extrusion#Rotate_Extrude
  23. OpenSCAD – Import STL import("C:DownloadsVT.stl",convexity=10); import(filepath, convexity=10); The import function lets you bring in existing 3D models into your project. Note: In Your filepath, backslashes need to be doubled. C:DownloadsMyStl.stl -> C:DownloadsMyStl.stl Tip: If you are using other people’s models, be sure to check and respect their licensing (http://www.thingiverse.com/thing:818805 by GlynnLo) Reference: https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Importing_Geometry
  24. OpenSCAD Basics – Transformations - Translate cube([22,22,5]); sphere(d=22, $fn=100); cube([22,22,5]); translate([11,11,0]) sphere(d=22, $fn=100); translate([x,y,z]) Translate MOVES objects– lets you define the how far to move along each of the axes. NO SEMICOLON AFTER IT (It’s not the end of the statement– we have to tell it what to translate) Reference: https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Transformations#translate
  25. OpenSCAD – Transformations – Rotate rotate([x,y,z]) Rotate angles the object. Guide to the axis is in your preview panel NO SEMICOLON AFTER IT (It’s not the end of the statement– we have to tell it what to rotate) It’s Okay if you Need Some Trial and Error : ) Reference: https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Transformations#rotate
  26. OpenSCAD - Transformations – Rotate rotate([0,-45,0]) cube([22,22,5]); rotate([0,0,30]) cube([22,22,5]); rotate([x,y,z]) rotate([30,-45,30]) cube([22,22,5]); Reference: https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Transformations#rotate
  27. OpenSCAD - Transformations – Resize resize([x,y,z],auto=true|false) Resize allows you to make your object different sizes where x, y, and z are your new dimensions NO SEMICOLON AFTER IT (It’s not the end of the statement– we have to tell it what to resize) If auto=false, anything left zero stays the same. If auto=true, anything left zero is sized proportionally. resize([200,0,10], auto=true) import("VT.stl", convexity=10); resize([200,0,10], auto=false) import("VT.stl", convexity=10); import("VT.stl", convexity=10); Reference: https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Transformations#resize
  28. OpenSCAD – CSG Modeling CSG stands for Constructive Solid Geometry.  You don’t need to remember that Do Remember: • Powerful! • Combines your primitive parts/objects. • Adding, Subtracting, Intersections Credit: https://en.wikipedia.org/wiki/Constructive_solid_geometry#/media/File:Csg_tree.png Reference: https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/CSG_Modelling
  29. OpenSCAD – CSG Modeling - Union Adds objects into a one union () { object1; object2; } union() { cube([5,10,5]); translate([5,10,2.5]) { rotate([0,-90,0]) cylinder(d=5, h=5, $fn=30); } translate([5,0,2.5]) { rotate([0,-90,0]) cylinder(d=5, h=5, $fn=30); } } Two cylinders and a cube After union – single rounded object Reference: https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/CSG_Modelling#union
  30. OpenSCAD – CSG Modeling - Difference Subtracts objects from each other difference () { object1; object2; } difference() { cube([5,10,5]); translate([5.5,10,2.5]) { rotate([0,-90,0]) cylinder(d=5, h=6, $fn=30); } translate([5.5,-1,2.5]) { rotate([0,-90,0]) cylinder(d=5, h=6, $fn=30); } } Two cylinders and a cube After “subtracting” the cylinders from the cube Reference: https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/CSG_Modelling#difference
  31. OpenSCAD – CSG Modeling - Difference Practical Use of Difference – Engraving Text! difference() { cube([5,10,5]); translate([5.5,10,2.5]) { rotate([0,-90,0]) cylinder(d=5, h=6, $fn=30); } translate([5.5,-1,2.5]) { rotate([0,-90,0]) cylinder(d=5, h=6, $fn=30); } translate([2,6.5,0.5]) rotate([90,0,-90]) linear_extrude(height=2) text("V", font="Old English Text MT", size=4); } Reference: https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/CSG_Modelling#difference
  32. OpenSCAD – CSG Modeling - Intersection Takes where both objects overlap (like a Venn Diagram) intersection () { object1; object2; } intersection() { cylinder(r=5,h=3); translate([4,0,0]) cylinder(r=5, h=3); } Two cylinders Intersection – an Almond Shape Reference: https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/CSG_Modelling#intersection
  33. OpenSCAD – CSG Modeling - Intersection Practical Use of Intersection – Curving Details! intersection() { sphere(r=9.25, $fn=100); resize([0,0,11],auto=false) resize([12,0,0], auto=true) import("VT.stl", convexity=10); } A sphere and a VT Logo Intersection – A curved VT Logo Reference: https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/CSG_Modelling#intersection
  34. OpenSCAD – CSG Modeling - Combinations Practical Use of Intersection – Curving Details! union() { sphere(r=9, $fn=100); intersection() { sphere(r=9.25, $fn=100); resize([0,0,11],auto=false) resize([12,0,0], auto=true) import("VT.stl", convexity=10); } } Add a slightly smaller sphere and we have a curved, embossed VT logo on a sphere. Reference: https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/CSG_Modelling
  35. OpenSCAD – Advanced - Modules To help readability and reusability, you can make modules. module name() { //your code } module base_sphere() { sphere(r=9, $fn=100); } module curved_VT() { intersection() { sphere(r=9.25, $fn=100); resize([0,0,11],auto=false) resize([12,0,0], auto=true) import("VT.stl", convexity=10); } } union() { base_sphere(); curved_VT(); } union() { sphere(r=9, $fn=100); intersection() { sphere(r=9.25, $fn=100); resize([0,0,11],auto=false) resize([12,0,0], auto=true) import("VT.stl", convexity=10); } } Reference: https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Modules Fun Fact – All objects in a model are already merged into one, no unions necessary
  36. OpenSCAD – Advanced - Loops Loops are powerful for repeated tasks for ( i = [start : increment : end] ) { //your code } for (i=[0:5:15]) { translate([i,0,0]) cylinder(r=1, h=15, $fn=36); } Translation– We are going to start at 0. Every 5 mm, draw a cylinder until we reach 15mm. Reference: https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Conditional_and_Iterator_Functions#For_Loop
  37. OpenSCAD – Advanced - Loops “Nested Loops” for ( i = [start : increment : end], j = [start : increment : end] ) { //your code } for (i=[0:5:15],j=[0:5:20]) { translate([i,j,0]) cylinder(r=1, h=15, $fn=36); } Translation– We going to end up with 20 pegs in 4 columns and 5 rows. Reference: https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Conditional_and_Iterator_Functions#For_Loop
  38. OpenSCAD – Troubleshooting Having Unexpected Results? • Check Your Syntax (maybe there’s a semi colon after a translate) • Check the Console for error messages (which would include a line number)
  39. OpenSCAD – Troubleshooting • echo allows you to send details to the Console • // allows you to comment out instructions so you can narrow down the culprit echo("i:", i, " j:", j);
  40. OpenSCAD – Troubleshooting • # allows you to have objects highlighted difference() { cube([5,10,5]); translate([5.5,10,2.5]) { rotate([0,-90,0]) cylinder(d=5, h=6, $fn=30); } translate([5.5,-1,2.5]) { #rotate([0,-90,0]) cylinder(d=5, h=6, $fn=30); } }
  41. OpenSCAD – Saving and Exporting • Be sure to Save your code often • When you’re ready to print, you’ll want to Export to STL file. • Pre-requisite– Do your official render (F6). • The system will remind you. : )
  42. OpenSCAD – Code Scavenging! OpenSCAD even comes with its OWN examples which you can open, review, and tweak to meet your needs.
  43. OpenSCAD – Code Scavenging! Thingiverse has a OpenSCAD area full of shared source code– just search “OpenSCAD” http://www.thingiverse.com/search?q =OpenSCAD You can download the final .STL file AND the original .SCAD files, so you can read and find out how it was made.
  44. OpenSCAD – Code Scavenging! • OpenSCAD Community Forums http://www.openscad.org/community.html • OpenSCAD reddit http://www.reddit.com/r/OpenSCAD/ • Good ole Google
  45. OpenSCAD – OpenJSCAD http://openjscad.org • Web-based • Has its own JavaScript, object-oriented language • BUT 95% of the OpenSCAD Language is supported Quick Tips • User Guide at https://github.com/Spiritdude/OpenJSCAD.org/wiki/User-Guide • //!OpenSCAD at the top tells it you’re using OpenSCAD • Shift-Enter in the “Text Editor” renders • Holding down the Left or Right Mouse Button lets you rotate the View Pane • Holding down Shift Left Mouse Button lets you pan in the View Pane
  46. THANK YOU!!! https://twitter.com/tgaw http://tgaw.wordpress.com http://www.shapeways.com/shops/tgaw http://www.instructables.com/member/VickyTGAW http://instagram.com/VickyTGAW Vicky Somma vicky@tgaw.com
Advertisement