modulesParametersEx1.scad 735 B

123456789101112131415161718192021222324252627
  1. module house(roof="flat",paint=[1,0,0]){
  2. color(paint)
  3. if(roof=="flat"){
  4. translate([0,-1,0])
  5. cube();
  6. } else if(roof=="pitched"){
  7. rotate([90,0,0])
  8. linear_extrude(height=1)
  9. polygon(points=[[0,0],[0,1],[0.5,1.5],[1,1],[1,0]],paths=[ [0,1,2,3,4] ]);
  10. } else if(roof=="domical"){
  11. translate([0,-1,0])
  12. union(){
  13. translate([0.5,0.5,1]) sphere(r=0.5,$fn=20);
  14. cube();
  15. }
  16. }
  17. }
  18. union(){
  19. house();
  20. translate([2,0,0]) house("pitched");
  21. translate([4,0,0]) house("domical",[0,1,0]);
  22. translate([6,0,0]) house(roof="pitched",paint=[0,0,1]);
  23. translate([8,0,0]) house(paint=[0,0,0],roof="pitched");
  24. translate([10,0,0]) house(roof="domical");
  25. translate([12,0,0]) house(paint=[0,0.5,0.5]);
  26. }