kcl-samples

gear_rack

gear_rack

KCL

// 100mm Gear Rack
// a flat bar or rail that is engraved with teeth along its length. These teeth are designed to mesh with the teeth of a gear, known as a pinion. When the pinion, a small cylindrical gear, rotates, its teeth engage with the teeth on the rack, causing the rack to move linearly. Conversely, linear motion applied to the rack will cause the pinion to rotate.

// Define constants
const length = 100
const pitch_height = 11.5
const width = 5
const height = 12
const min_height = 10.875

// Create the body of the rack
const rackBody = startSketchOn('XY')
  |> startProfileAt([-length / 2, 0], %)
  |> line([length, 0], %)
  |> line([0, min_height], %)
  |> line([-length, 0], %)
  |> close(%)
  |> extrude(width, %)

// Create a function for sketch of a single tooth
fn tooth = () => {
  const toothSketch = startSketchOn('XY')
  |> startProfileAt([-length / 2 + 0.567672, min_height], %)
  |> tangentialArc([0.157636, 0.110378], %)
  |> line([0.329118, 0.904244], %)
  |> tangentialArc([0.157636, 0.110378], %)
  |> line([0.186505, 0], %)
  |> tangentialArc([0.157636, -0.110378], %)
  |> line([0.329118, -0.904244], %)
  |> tangentialArc([0.157636, -0.110378], %)
  |> close(%)
  |> extrude(width, %)
  return toothSketch
}

// Pattern the single tooth over the length of the rack body
const teeth = tooth()
  |> patternLinear3d({
       axis: [10, 0, 0],
       distance: 1.570796,
       repetitions: 62
     }, %)

// Sketch and extrude the first end cap. This is a partial tooth
const endCapTooth = startSketchOn('XY')
  |> startProfileAt([-length / 2, 11.849525], %)
  |> line([0.314524, -0.864147], %)
  |> tangentialArc([0.157636, -0.110378], %)
  |> lineTo([-length / 2, min_height], %)
  |> close(%)
  |> extrude(width, %)

//Sketch and extrude the second end cap. This is a partial tooth
const endCapTooth2 = startSketchOn('XY')
  |> startProfileAt([length / 2, 11.849525], %)
  |> line([-0.314524, -0.864147], %)
  |> tangentialArc([-0.157636, -0.110378], %)
  |> lineTo([length / 2, min_height], %)
  |> close(%)
  |> extrude(width, %)