Skip to content

Instantly share code, notes, and snippets.

@massayoshi
Last active September 15, 2016 03:00
Show Gist options
  • Save massayoshi/6a18eaf90a9f3af068684304b1a9b3a1 to your computer and use it in GitHub Desktop.
Save massayoshi/6a18eaf90a9f3af068684304b1a9b3a1 to your computer and use it in GitHub Desktop.
Primeiros passos no OpenSCAD
$fn=64;
module added(){
hull(){
cube([235,60,6]);
translate([0,0,6]) cube([160,60,18]);
}
}
module taken(lb){
hull(){
translate([(160/2)+13,0,3]) cylinder(r=9, h=20);
translate([500,0,3]) cylinder(r=9, h=20);
}
hull(lb){
translate([(160/2)+13,0,-3]) cylinder(r=2.5, h=20);
translate([(160/2)+13+lb,0,-3]) cylinder(r=2.5, h=20);
}
}
module full() {
difference(){
added();
taken(lb=0);
mirror([1,0,0]) taken(lb=10);
}
}
intersection(){
//full();
//mirror([1,0,0]) translate([0,-40-5]) cube([200,100,100]);
}
xxx=35;
yyy=35;
zzz=35;
rrr=2;
thickness=2;
cut_width=20;
cut_margin=7.5 ;
difference(){
roundedcube(xxx,yyy,zzz,rrr);
translate([thickness/2,thickness/2,thickness]) roundedcube(xxx-thickness,yyy-thickness,zzz,rrr);
//translate([-1,cut_margin,1]) cube([thickness*2,cut_width,zzz]);
//translate([xxx-thickness,cut_margin,1]) cube([thickness*2,cut_width,zzz]);
translate([cut_margin,-1,thickness]) cube([cut_width,thickness*2,zzz]);
translate([cut_margin,yyy-thickness,thickness]) cube([cut_width,thickness*2,zzz]);
}
module roundedcube(xx,yy,zz,rr){
hull(){
translate([rr,rr,0]) cylinder(r=rr,zz);
translate([xx-rr,rr,0]) cylinder(r=rr,zz);
translate([rr,yy-rr,0]) cylinder(r=rr,zz);
translate([xx-rr,yy-rr,0]) cylinder(r=rr,zz);
}
}
difference(){
color("Blue") translate([-(xxx-1),0,0]) roundedcube(xxx,yyy,zzz,rrr);
translate([(thickness/2)-(xxx-1),thickness/2,thickness]) roundedcube(xxx-thickness,yyy-thickness,zzz+2,rrr);
translate([cut_margin-(xxx-1),-1,thickness]) cube([cut_width,thickness*2,zzz]);
translate([cut_margin-(xxx-1),yyy-thickness,thickness]) cube([cut_width,thickness*2,zzz]);
}
difference(){
color("Red") translate([(xxx-1),0,0]) roundedcube(xxx,yyy,zzz,rrr);
translate([(thickness/2)+(xxx-1),thickness/2,thickness]) roundedcube(xxx-thickness,yyy-thickness,zzz+2,rrr);
translate([cut_margin+(xxx-1),-1,thickness]) cube([cut_width,thickness*2,zzz]);
translate([cut_margin+(xxx-1),yyy-thickness,thickness]) cube([cut_width,thickness*2,zzz]);
}
difference(){
color("Purple") translate([(xxx-1)*2,0,0]) roundedcube(xxx,yyy,zzz,rrr);
translate([(thickness/2)+(xxx-1)*2,thickness/2,thickness]) roundedcube(xxx-thickness,yyy-thickness,zzz,rrr);
translate([cut_margin+(xxx-1)*2,-1,thickness]) cube([cut_width,thickness*2,zzz]);
translate([cut_margin+(xxx-1)*2,yyy-thickness,thickness]) cube([cut_width,thickness*2,zzz]);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment