KittyCAD / modeling-app

The KittyCAD modeling app.
https://kittycad.io/modeling-app/download
MIT License
375 stars 32 forks source link

Linter Showing Up on Std Lib Params #3195

Closed jgomez720 closed 2 months ago

jgomez720 commented 2 months ago

Description

Our linter is telling me to change x_axis: (a parameter needed for a custom plane) to lowerCamelCase.

Screenshot

Screenshot 2024-07-30 at 1 39 14 PM

KCL

// Pipe and Flange Assembly
// A crucial component in various piping systems, designed to facilitate the connection, disconnection, and access to piping for inspection, cleaning, and modifications. This assembly combines pipes (long cylindrical conduits) with flanges (plate-like fittings) to create a secure yet detachable joint.

// Define Constants
const hexCapRatio = 0.275
const capRatio = 2 / 3
const startingPoint = [1.375, 0, 0]
const flangeThickness = .125
const flangeBaseDia = 2
const boreHeight = 1
const flangePipeDia = 1
const mountingHoleDia = 0.425
const screwDia = 0.375
const tol = 0.010
const hexNutScale = 0.90
const wallThickness = 0.5
const screwLength = 1.125
const washerThickness = 0.0625

const workingPlane = {
  plane: {
    origin: { x: 0, y: flangeThickness, z: 0 },
    x_axis: { x: 0, y: 0, z: 1 },
    y_axis: { x: 1, y: 0, z: 0 },
    z_axis: { x: 0, y: 1, z: 0 }
  }
}

// Socket head cap screw function
fn capScrew = (originStart, length, dia, capDia, capHeadLength) => {
  const screwHead = startSketchOn({
         plane: {
           origin: {
             x: originStart[2],
             y: originStart[1],
             z: originStart[0]
           },
           x_axis: { x: 1, y: 0, z: 0 },
           y_axis: { x: 0, y: 0, z: 1 },
           z_axis: { x: 0, y: 1, z: 0 }
         }
       })
    |> circle([0, 0], capDia / 2, %)
    |> extrude(capHeadLength, %)
  const hexPattern = startSketchOn(screwHead, 'end')
    |> startProfileAt([
         0 + hexCapRatio * dia / capRatio,
         originStart[0]
       ], %)
    |> angledLine({
         angle: 240,
         length: hexCapRatio * dia / capRatio
       }, %)
    |> angledLine({
         angle: 180,
         length: hexCapRatio * dia / capRatio
       }, %)
    |> angledLine({
         angle: 120,
         length: hexCapRatio * dia / capRatio
       }, %)
    |> angledLine({
         angle: 60,
         length: hexCapRatio * dia / capRatio
       }, %)
    |> angledLine({
         angle: 0,
         length: hexCapRatio * dia / capRatio
       }, %)
    |> close(%)
    |> extrude(-0.0625, %)
  return hexPattern
}

// Washer function
fn washer = (plane, originStart, thk, innerDia, outerDia) => {
  const washerSketch = startSketchOn(plane)
    |> circle([originStart[0], originStart[1]], outerDia / 2, %)
    |> hole(circle([originStart[0], originStart[1]], innerDia / 2, %), %)
    |> extrude(thk, %)
  return washerSketch
}

// Hex nut function
fn hexNut = (originStart, thk, innerDia) => {
  const hexNutSketch = startSketchOn({
         plane: {
           origin: {
             x: originStart[0],
             y: -wallThickness - washerThickness,
             z: originStart[1]
           },
           x_axis: { x: 0, y: 0, z: 1 },
           y_axis: { x: 1, y: 0, z: 0 },
           z_axis: { x: 0, y: 1, z: 0 }
         }
       })
    |> startProfileAt([0 + innerDia * hexNutScale, 0], %)
    |> angledLine({
         angle: 240,
         length: innerDia * hexNutScale
       }, %)
    |> angledLine({
         angle: 180,
         length: innerDia * hexNutScale
       }, %)
    |> angledLine({
         angle: 120,
         length: innerDia * hexNutScale
       }, %)
    |> angledLine({
         angle: 60,
         length: innerDia * hexNutScale
       }, %)
    |> angledLine({ angle: 0, length: innerDia * .90 }, %)
    |> close(%)
    |> hole(circle([0, 0], innerDia / 2, %), %)
    |> extrude(-thk, %)
  return hexNutSketch
}

// Mounting holes pattern
const mountingHolePattern = startSketchOn('XZ')
  |> circle([startingPoint[1], startingPoint[0]], screwDia / 2 + tol, %)
  |> patternCircular2d({
       arcDegrees: 360,
       center: [0, 0],
       repetitions: 6,
       rotateDuplicates: true
     }, %)

// Sketch and revolve the pipe
const pipe = startSketchOn('XY')
  |> startProfileAt([flangePipeDia / 2 - tol, 0], %)
  |> line([0, -2], %)
  |> angledLine({ angle: -60, length: .5 }, %)
  |> line([0, -1], %)
  |> line([-flangeThickness, 0], %)
  |> line([0, 1], %)
  |> angledLine({ angle: -240, length: .5 }, %)
  |> line([0, 5], %)
  |> angledLine({ angle: 60, length: .5 }, %)
  |> line([0, 1], %)
  |> line([flangeThickness, 0], %)
  |> line([0, -1], %)
  |> angledLine({ angle: 240, length: .5 }, %)
  |> close(%)
  |> revolve({ axis: 'y' }, %)

// Sketch and extrude the wall
const wall = startSketchOn('XZ')
  |> startProfileAt([-4, -4], %)
  |> line([0, 8], %)
  |> line([8, 0], %)
  |> line([0, -8], %)
  |> close(%)
  |> hole(mountingHolePattern, %)
  |> hole(circle([0, 0], flangePipeDia / 2, %), %)
  |> extrude(wallThickness, %)

// Sketch and revolve the flange
const flangeBase = startSketchOn('XZ')
  |> circle([0, 0], flangeBaseDia, %)
  |> hole(mountingHolePattern, %)
  |> hole(circle([0, 0], flangePipeDia / 2, %), %)
  |> extrude(-flangeThickness, %)

// Create the washer and pattern around the flange
washer(workingPlane, [startingPoint[0], startingPoint[1]], 0.0625, screwDia + tol, 0.625)
  |> patternCircular3d({
       axis: [0, 1, 0],
       center: [0, 0, 0],
       repetitions: 6,
       arcDegrees: 360,
       rotateDuplicates: true
     }, %)

// Create the cap screw and pattern around the flange
capScrew([
       1.375,
       flangeThickness + washerThickness,
       0
     ], screwLength, screwDia, 0.5, 0.25)
  |> patternCircular3d({
       axis: [0, 1, 0],
       center: [0, 0, 0],
       repetitions: 6,
       arcDegrees: 360,
       rotateDuplicates: true
     }, %)

const screwBody = startSketchOn({
         plane: {
           origin: {
             x: startingPoint[2],
             y: startingPoint[1],
             z: startingPoint[0]
           },
           x_axis: { x: 0, y: 0, z: 1 },
           y_axis: { x: 1, y: 0, z: 0 },
           z_axis: { x: 0, y: 1, z: 0 }
         }
       })
    |> circle([0, 0], screwDia / 2, %)
    |> extrude(-screwLength, %)
    |> patternCircular3d({
       axis: [0, 1, 0],
       center: [0, 0, 0],
       repetitions: 6,
       arcDegrees: 360,
       rotateDuplicates: true
     }, %)

const backSideWasherPlane = {
  plane: {
    origin: { x: 0, y: -wallThickness - washerThickness, z: 0 },
    x_axis: { x: 0, y: 0, z: 1 },
    y_axis: { x: 1, y: 0, z: 0 },
    z_axis: { x: 0, y: 1, z: 0 }
  }
}

washer(workingPlane, [startingPoint[0], startingPoint[1]], 0.0625, screwDia + tol, 0.625)
  |> patternCircular3d({
       axis: [0, 1, 0],
       center: [0, 0, 0],
       repetitions: 6,
       arcDegrees: 360,
       rotateDuplicates: true
     }, %)

  // Create the hex nut and pattern around the flange
  hexNut([startingPoint[1], startingPoint[0]], .25, screwDia + tol)
  |> patternCircular3d({
  axis: [0, 1, 0],
  center: [0, 0, 0],
  repetitions: 6,
  arcDegrees: 360,
  rotateDuplicates: true
}, %)
jessfraz commented 2 months ago

yeah you need to update your code :) in a later version im removing snake case, fix yo code ;)

jgomez720 commented 2 months ago

oh lol aight