Skip to content

Latest commit

 

History

History
1378 lines (786 loc) · 28.6 KB

stemfie.scad.md

File metadata and controls

1378 lines (786 loc) · 28.6 KB

LibFile: stemfie.scad

Author: Brendon Collecutt

Contact: 1976016983@qq.com

This file is part of Stemfie_OpenSCAD.

Stemfie_OpenSCAD is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

Stemfie_OpenSCAD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with Stemfie_OpenSCAD. If not, see https://www.gnu.org/licenses/.

Please check https://stemfie.org/license for more information or before using stemfie commercially.

OpenSCAD script for creating Stemife.org parts.

Feel free to adapt and improve and share your OpenSCAD script (please contact Paulo Kiefe)

Contact: paulo.kiefe@stemfie.org (https://stemfie.org)

To use, add the following lines to the beginning of your file:

include <stemfie.scad>

Table of Contents

  1. Section: Universal constants

  2. Section: Stemfie Parts

    1. Subsection: Beams
    2. Subsection: Braces
    3. Subsection: Fasteners
    4. Subsection: Washers and Spacers
  3. Section: Helper Modules

    1. Subsection: General
    2. Subsection: Shafts
    3. Subsection: Nuts and Washers
    4. Subsection: Braces
    5. Subsection: Beams
    6. Subsection: Block Unit Translation Shortcuts

Section: Universal constants

Constant: BU

Description:

Universal voxel block unit (mm) in Stemfie (BlockUnit)


Constant: HoleRadius

Description:

Universal radius (mm) of the connection hole


Constant: FragmentNumber

Description:

Universal tesselation value of curved surfaces


Constant: Chamfer

Description:

Chamfer size adjustment value for all edges


Constant: BevelWidth

Description:

Width of the top section of beveled edges. Must be less or equal to twice printer nozzle diameter to ensure level top surface.


Constant: Clearance

Description:

Distance between hole and shafts and other parts that need to move relatively to each other.


Constant: ShaftRadius

Description:

Universal radius (mm) of the connection shaft


Constant: PinRadius

Description:

Universal radius (mm) of the connection pin


Constant: ShaftFlat

Description:

Universal distance (mm) between two flat sides of the shafts.


Constant: FastenerFlat

Description:

Universal distance (mm) between two flat sides of pin and screw fasteners.


Constant: ThreadPitch

Description:

Universal pitch (mm) for Stemfie threaded fasteners


Section: Stemfie Parts

Subsection: Beams

Module: beam_block()

Usage:

  • beam_block(size, holes, center);

Description:

Creates a Stemfie beam with holes.

Arguments:

By Position What it does
size Size of block to create in block units.
holes Array of booleans in xyz order for which directions to create holes or a single boolean for all directions.

Example 1: Standard Stemfie beam

beam\_block() Example 1

include <stemfie.scad>
beam_block(3);


Example 2: Stemfie beam with vertical holes only.

beam\_block() Example 2

include <stemfie.scad>
beam_block(3, holes = [false, false, true], center = false);


Example 3: Stemfie 3D "beam"

beam\_block() Example 3

include <stemfie.scad>
beam_block([3, 2, 2]);


Module: beam_threaded()

Usage:

  • beam_threaded(length);

Description:

Creates a stemfie beam with threaded ends.


Example 1:

beam\_threaded() Example 1

include <stemfie.scad>
beam_threaded(4);


Module: beam_cross()

Usage:

  • beam_cross(lengths);

Description:

Overlaps two Stemfie beams. It can be used to create 'V', 'L', 'T' and 'X' shapes.

Arguments:

By Position What it does
lengths Array of 2, 3 or 4 integers. Lengths extending from intersection block with clockwise ordering.

Example 1: 'V' beam

beam\_cross() Example 1

include <stemfie.scad>
beam_cross([3,3]);


Example 2: 'L' beam

beam\_cross() Example 2

include <stemfie.scad>
beam_cross([5,3]);


Example 3: 'T' beam

beam\_cross() Example 3

include <stemfie.scad>
beam_cross([2,3,2]);


Example 4: 'X' beam

beam\_cross() Example 4

include <stemfie.scad>
beam_cross([2,2,2,2]);


Subsection: Braces

Module: brace()

Usage:

  • brace(size, <h=>, <holes=>);

Description:

Creates a Stemfie brace with holes.

Arguments:

By Position What it does
size Length of brace to create in block units.
h height of brace
holes Set to false to create blank brace.

Example 1: Standard Stemfie brace

brace() Example 1

include <stemfie.scad>
brace(3);


Example 2: Double thickness blank brace

brace() Example 2

include <stemfie.scad>
brace(3, h = 0.5, holes = false);


Module: brace_cross()

Usage:

  • brace_cross(lengths, <h>);

Description:

Overlaps two Stemfie brace. It can be used to create 'V', 'L', 'T' and 'X' shapes.

Arguments:

By Position What it does
lengths Array of 2, 3 or 4 integers. Lengths extending from intersection block with clockwise ordering.
h Height of brace, default = 0.25BU

Example 1: 'V' brace

brace\_cross() Example 1

include <stemfie.scad>
brace_cross([3,3]);


Example 2: 'L' brace

brace\_cross() Example 2

include <stemfie.scad>
brace_cross([5,3]);


Example 3: 'T' brace

brace\_cross() Example 3

include <stemfie.scad>
brace_cross([2,3,2]);


Example 4: Double thickness 'X' brace

brace\_cross() Example 4

include <stemfie.scad>
brace_cross([1, 1, 1, 1], 0.5);


Module: brace_arc()

Usage:

  • brace_arc(r, angle, h = 0.25, holes = 2);

Description:

Creates a circular arc brace. Detects when hole spacing is less than 1 block unit and reduces the number of holes as necessary. If the angle is too big and the end point overlaps the start point then the angle is set to 360 and a circular brace is created.

Arguments:

By Position What it does
r Radius in block units to the center of the brace.
angle Angle between start and end points.

Example 1: Holes with 60 degree spacing have 1 radius spacing.

brace\_arc() Example 1

include <stemfie.scad>
brace_arc(2, 120, holes = 3);


Example 2: Number of holes are reduced to fit of brace.

brace\_arc() Example 2

include <stemfie.scad>
brace_arc(3, 360, holes = 100);


Example 3: Angle adjusted to 360 to prevent overlap.

brace\_arc() Example 3

include <stemfie.scad>
brace_arc(3, 350, holes = 12);


Subsection: Fasteners

Module: screw()

Usage:

  • screw(thread_length, shaft_length = 0.125, screw_head = true);

Description:

Creates a stemfie screw.


Example 1: Add 0.125 BU of unthreaded shaft to get that standard look.

screw() Example 1

include <stemfie.scad>
screw(1.375, 0.125);


Example 2:

screw() Example 2

include <stemfie.scad>
screw(0.5, 3);


Example 3:

screw() Example 3

include <stemfie.scad>
screw(1.5, screw_head = false);


Module: pin

Usage:

  • pin(length, head = true);

Description:

Creates an almost standard stemfie pin.


Example 1:

pin Example 1

include <stemfie.scad>
pin(length = 1, head = true);


Module: nut()

Usage:

  • nut_open(length = 5/BU, center = true);

Description:

Creates a threaded open nut.


Example 1: Standard 5mm open nut

nut() Example 1

include <stemfie.scad>
nut_open();


Example 2: 1 block unit threaded nut.

nut() Example 2

include <stemfie.scad>
nut_open(1);


Subsection: Washers and Spacers

Module: spacer()

Usage:

  • module spacer(length = 0.25, center = true);

Description:

Creates a free spacer to fit over a shaft or fastener.


Example 1:

spacer() Example 1

include <stemfie.scad>
spacer(length = 0.5, center = false);


Module: fixed_washer()

Usage:

  • fixed_washer(length = 0.25, center = true);

Description:

Creates a fixed washer to fit a fastener.


Example 1: Standard 0.25 block unit fixed washer

fixed\_washer() Example 1

include <stemfie.scad>
fixed_washer();


Example 2: 10mm fixed washer

fixed\_washer() Example 2

include <stemfie.scad>
fixed_washer(10 / BU);


Section: Helper Modules

Subsection: General

Module: hole()

Usage:

  • hole(depth = 1, neg = true, bevel = [true,true]);

Description:

Create a circular standard sized hole with beveled top and bottom.

Arguments:

By Position What it does
depth The depth of the hole in base units.
neg true to create hole cavity, false to create sleeve and bevel.
bevel [bevel on top, bevel on bottom]

Example 1:

hole() Example 1

include <stemfie.scad>
difference()
{
  BU_cube();
  hole(depth = 1, neg = true);
}


Example 2:

hole() Example 2

include <stemfie.scad>
hole(depth = 1, neg = false);


Example 3:

hole() Example 3

include <stemfie.scad>
difference()
{
  hole(depth = 1, neg = false);
  hole(depth = 1, neg = true);
}


Module: cutout()

Usage:

  • cutout(depth, neg = true, bevel = [true,true]);

Description:

Create an irregular sized hole with beveled top and bottom. Children should be a convex 2D shape.

Arguments:

By Position What it does
depth The depth of the cutout in base units.
neg true to create cutout cavity, false to create sleeve and top bevel.
bevel [bevel on top, bevel on bottom]

Example 1: Create a brace with a slot down most of the length.

cutout() Example 1

include <stemfie.scad>
difference()
{
  union()
  {
    brace(4, holes = false);

    cutout(depth = 0.25, neg = false)
      BU_Tx(1)
        hole_slot(length = 3);
  }
  cutout(depth = 0.25, neg = true)
    BU_Tx(1)
      hole_slot(length = 3);
}


Example 2: Shaft shaped hole in brace.

cutout() Example 2

include <stemfie.scad>
difference()
{
  union()
  {
    brace(4, holes = false);
      cutout(depth = 0.25, neg = false)
        offset(r=Clearance)
          shaft_profile();
  }
  cutout(depth = 0.25, neg = true)
    offset(r=Clearance)
      shaft_profile();
}


Module: hole_grid()

Usage:

  • hole_grid(size, <l=1>, <neg=true>);

Description:

Creates a rectangular array of holes centered on the origin with block unit spacing.

Arguments:

By Position What it does
size List with number of holes in X and Y directions.
l See hole()
neg See hole()

Example 1: Create a 4x5 block with vertical holes.

hole\_grid() Example 1

include <stemfie.scad>
difference()
{
  BU_cube([4,5,1]);
  hole_grid([4,5]);
}


Example 2: Create a 4x5x0.25 block unit plate with holes.

hole\_grid() Example 2

include <stemfie.scad>
difference()
{
  union()
  {
    bevel_plate(h = 0.25)
      offset(r = BU/2)
        square([3 * BU, 4 * BU], center = true);
    hole_grid([4,5], l = 0.25, neg = false);
  }
  hole_grid([4,5], l = 0.25);
}


Module: hole_list()

Usage:

  • hole_list(list, <l=1>, <neg=true>);

Description:

Creates a rectangular array of holes centered on the origin with block unit spacing.

Arguments:

By Position What it does
list List with location of holes by X,Y co-ordinates in block units.
l See hole()
neg See hole()

Example 1: Create brace with custom hole locations

hole\_list() Example 1

include <stemfie.scad>
difference()
{
  union()
  {
    brace(5, holes = false);
    hole_list([[0,0],[4,0]], l = 0.25, neg = false);
  }
  hole_list([[0,0],[4,0]], l = 0.25);
}


Module: hole_slot()

Usage:

  • hole_slot(length);

Description:

Create a 2D slot profile with radius equal to HoleRadius and length l.

Arguments:

By Position What it does
l Length of slot in block units.

Example 1:

hole\_slot() Example 1

include <stemfie.scad>
hole_slot(2);


Module: BU_slot()

Usage:

  • BU_slot(length);

Description:

Create a 2D slot profile with radius BU/2

Arguments:

By Position What it does
l Length of slot in block units.

Example 1:

BU\_slot() Example 1

include <stemfie.scad>
BU_slot(2);


Module: slot()

Usage:

  • slot(length, r);

Description:

Create a 2D slot profile.

Arguments:

By Position What it does
length Length of slot in block units.

Example 1:

slot() Example 1

include <stemfie.scad>
slot(2, r = 2 + Clearance);


Module: thread()

Usage:

  • thread(length, internal = false, bevel = false, center = true);
  • thread(length, internal = false, bevel = [false, false], center = true);

Example 1:

thread() Example 1


include <stemfie.scad>
difference()
{
   BU_cube([1,1,1]);

   thread(2, internal = true, center = true, bevel = [true,false]);
}

Module: bevel

Usage:

  • bevel(offs = 0, neg = true);

Description:

Creates a bevel from a convex 2D profile using Chamfer.


Figure 1: Calling bevel() on a concave shape results in a convex bevel.

bevel Figure 1



Figure 2: Instead break shape into convex shapes call bevel on each shape.

bevel Figure 2



Example 1:

bevel Example 1

include <stemfie.scad>
bevel(neg = false)
  circle(r = HoleRadius);


Subsection: Shafts

Module: shaft_profile()

Usage:

  • shaft_profile();

Description:

Creates a stemfie 2D profile for creating shafts and screws.


Example 1:

shaft\_profile() Example 1

include <stemfie.scad>
shaft_profile();


Module: fastener_profile()

Usage:

  • fastener_profile();

Description:

Creates a stemfie 2D profile for creating pins and screws.


Example 1:

fastener\_profile() Example 1

include <stemfie.scad>
fastener_profile();


Module: pin_profile()

Usage:

  • pin_profile();

Description:

Creates a stemfie 2D profile for creating pins.


Example 1:

pin\_profile() Example 1

include <stemfie.scad>
pin_profile();


Module: fastener_head_profile()

Usage:

  • fastener_head_profile()

Description:

Creates a stemfie 2D profile for creating shafts and screw heads.


Example 1:

fastener\_head\_profile() Example 1

include <stemfie.scad>
fastener_head_profile();


Module: fastener_head()

Usage:

  • fastener_head()

Description:

Creates a stemfie fastener head for creating pins and screws.


Example 1:

fastener\_head() Example 1

include <stemfie.scad>
fastener_head();


Module: shaft()

Usage:

  • shaft(length, beveled_ends)

Description:

Creates a stemfie blank shaft for creating shafts and screws.

Arguments:

By Position What it does
length The length of the shaft in base units.
beveled_ends Bevel ends of shaft using the global Chamfer setting.

Example 1: Shaft with beveled ends

shaft() Example 1

include <stemfie.scad>
shaft(4, true);


Example 2: Shaft without beveled ends

shaft() Example 2

include <stemfie.scad>
shaft(4, false);


Subsection: Nuts and Washers

Module: nut_blank()

Usage:

  • nut_blank(length = 0.25, center = true)

Description:

Creates a nut template with solid interior that can be used to create nuts and washers.


Example 1:

nut\_blank() Example 1

include <stemfie.scad>
nut_blank(0.5);


Subsection: Braces

Subsection: Beams

Module: BU_cube()

Usage:

  • BU_cube(size = [1,1,1]);

Description:

Create a beveled cube of given size in block units.

Arguments:

By Position What it does
BU_cube Size of cube

Example 1:

BU\_cube() Example 1

include <stemfie.scad>
BU_cube();


Example 2:

BU\_cube() Example 2

include <stemfie.scad>
BU_cube([3,1,1]);


Subsection: Block Unit Translation Shortcuts

Modified from Rudolf Huttary's shortcuts.scad

Module: BU_T()

Usage:

  • BU_T(x, y, z);
  • BU_T([x, y, z]);

Description:

Shortcut for translate([x * BU, y * BU, z * BU])


Module: BU_TK()

Usage:

  • BU_TK(x, y, z);
  • BU_TK([x, y, z]);

Description:

Children at origin and translation.


Example 1: One block unit cube centered at origin and one at [3 * BU, 0, 0]

BU\_TK() Example 1

include <stemfie.scad>
BU_TK(3, 0 , 0) BU_cube();


Module: BU_Tx()

Usage: BU\_Tx(x)

Description:

Shortcut for translate([x * BU, 0, 0])


Module: BU_Ty()

Usage: BU\_Ty(y)

Description:

Shortcut for translate([0, y * BU, 0])


Module: BU_Tz()

Usage: BU\_Tz(z)

Description:

Shortcut for translate([0, 0, z * BU])


Module: BU_TKx()

Usage: BU\_TKx(x)

Description:

Alternative for BU_TK(x=x)


Module: BU_TKy()

Usage: BU\_TKy(z)

Description:

Alternative for BU_TK(y=y)


Module: BU_TKz()

Usage: BU\_TKz(z)

Description:

Alternative for BU_TK(z=z)