Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //--------------------------------
- // Parametric Die Model
- // Keith Olson
- // OpenSCAD
- //--------------------------------
- // OpenSCAD uses millimeters (mm) for units.
- // Distance functions are both for conversion and to state plainly that a number is a
- // measurement, not just a value.
- // Fractions are interpreted as formulas: '1 3/4"' = inches(1+3/4) = 1.75
- function mm(x = 1) = x;
- function cm(x = 1) = x * 10;
- function inches(x = 1) = x * 25.40000;
- function feet(x = 1) = x * 25.40000 * 12;
- $fn=72; // (Circles are divided in $fn line segments.)
- dieScale=mm(20);
- dieSize=[dieScale,dieScale,dieScale];
- pipWidth=dieScale/6;
- pipHeight=pipWidth/2;
- pipSpacing=dieScale/4;
- pipPatterns=[[0,0,0,
- 1,
- 0,0,0], //1
- [1,0,0,
- 0,
- 0,0,1], //2
- [1,0,0,
- 1,
- 0,0,1], //3
- [1,1,0,
- 0,
- 0,1,1], //4
- [1,1,0,
- 1,
- 0,1,1], //5
- [1,1,1,
- 0,
- 1,1,1] //6
- ];
- pipPlacement=[[0,0,0], [2,0,0],
- [0,1,0], [1,1,0], [2,1,0],
- [0,2,0], [2,2,0]
- ];
- pipRotation=[[+0,+0,+0], //1
- [+0,-1,+0], //2
- [+1,+0,+0], //3
- [-1,+0,+0], //4
- [+0,+1,+0], //5
- [+2,+0,+0] //6
- ];
- difference(){
- cube(dieSize,center=true);
- for (pip=[1:6]){
- rotate(pipRotation[pip-1]*90)
- translate([-dieScale/4,-dieScale/4,dieScale/2-pipHeight+0.01])
- DisplayPips(pip);
- }
- }
- module DisplayPips(pipVal){
- for (jj=[0:6]){
- if (pipPatterns[pipVal-1][jj]){
- translate(pipPlacement[jj]*pipSpacing)
- cylinder(d1=0,d2=pipWidth, h=pipHeight);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement