Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //--------------------------------
- // Hex Grid Ruler
- // Keith Olson
- // CC 2022
- // OpenSCAD 2021.01
- //--------------------------------
- // Thingiverse Customizer Docs: http://customizer.makerbot.com/docs
- // 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' = '1+3/4' = 1.75
- function mm(x = 1) = x * 1.00000;
- function cm(x = 1) = x * 10.00000;
- function m(x = 1) = x * 1000.00000;
- function inches(x = 1) = x * 25.40000;
- function feet(x = 1) = x * 25.40000 * 12;
- function yards(x = 1) = x * 25.40000 * 12 * 3;
- function twice(x = 1) = x * 2.00000;
- function half(x = 1) = x * 0.50000;
- // Segments used for circles/cylinders have their endpoints on the radius. This means that
- // cylinders used for holes will be too small; the *midpoints* need to be on the radius,
- // not the *endpoints*. This function returns properly sized radjj for holes.
- function midpoint_radius (endpoint_radius, num_facets) = endpoint_radius / cos(360/(num_facets*2));
- // OpenSCAD uses degrees (deg) for units.
- // Angle functions are both for conversion and to state plainly that a number is a
- // measurement, not just a value.
- function deg(x = 1) = x;
- function rad(x = 1) = x * (180 / _pi);
- // From current origin, returns the vector pointing to x,y,z.
- function rotateto(x=1,y=1,z=1) = [0,acos(z/norm([x,y,z])),atan2(y,x)];
- draft_quality = 12; // [12:6:360]
- final_quality = 72; // [12:6:360]
- // Automatically chooses quality level depending on if previewing <F5> or rendering <F6>.
- smoothness =$preview ? draft_quality : final_quality; // (Circles are divided in $fn line segments.)
- // echo($preview,smoothness);
- $fn = smoothness;
- //--------------------------------------------------------------------------------------------
- /*/
- //*/
- ;
- //(in mm)
- Hex_Width = 20; // [1:0.1:2000]
- //How many hexes wide (must be an even number)
- Hex_Count = 10; // [2:2:200]
- //(Should be slightly wider than the tip of the pen you'll be using.)
- Slot_Width = 1;
- Ruler_Width = Hex_Width * 1.5;
- Ruler_Length = Hex_Width * Hex_Count + Hex_Width * 1.5;
- Ruler_Thickness = 2;
- Hex_Height = twice(tan(60) * (Hex_Width/4));
- Hex_Side = half(Hex_Width);
- Hex_Point_Set = [[0,0,60], // X, Y, L, A
- [Hex_Width*0.25,half(Hex_Height),0],
- [Hex_Width*0.75,half(Hex_Height),-60],
- [Hex_Width*1.00,0,-60],
- [Hex_Width*1.25,-half(Hex_Height),0],
- [Hex_Width*1.75,-half(Hex_Height),60]];
- module drawcapsule(capsule_length = 10, capsule_width = 1, capsule_depth = 2)
- {
- translate([0,0,-half(capsule_depth)]) cylinder(d=capsule_width, h = capsule_depth);
- translate([0,-half(capsule_width),-half(capsule_depth)]) cube([capsule_length,capsule_width,capsule_depth]);
- translate([capsule_length,0,-half(capsule_depth)]) cylinder(d=capsule_width, h =capsule_depth);
- }
- difference()
- {
- translate([Hex_Width * 0.75,half(Ruler_Width),0])
- difference()
- {
- translate([-half(Hex_Width * 1.50), -half(Ruler_Width),0])
- cube([Ruler_Length, Ruler_Width, Ruler_Thickness]);
- union()
- {
- for(ii=[0:2:Hex_Count-1])
- {
- for(jj=[0:5])
- {
- translate([ii*Hex_Width+Hex_Point_Set[jj][0], Hex_Point_Set[jj][1], -1])
- rotate([0,0,Hex_Point_Set[jj][2]])
- drawcapsule(capsule_length = Hex_Side, capsule_width = Slot_Width, capsule_depth = Ruler_Thickness + 20);
- }
- }
- }
- }
- //color("black")
- translate([Hex_Width * 0.125,Hex_Width * 0.125,half(Ruler_Thickness)])
- linear_extrude(height = Ruler_Thickness)
- text(text = str(Hex_Width,"mm"),
- font = "Arial:style=Black",
- size = Ruler_Width * 0.15);
- //color("black")
- translate([Hex_Width * 0.125,Hex_Width * 0.45,half(Ruler_Thickness)])
- linear_extrude(height = Ruler_Thickness)
- text(text = str(Hex_Count,"x"),
- font = "Arial:style=Black",
- size = Ruler_Width * 0.15);
- }
- ;
Advertisement
Add Comment
Please, Sign In to add comment