Skip to content

Commit

Permalink
Update Snapshot Workflow and KCL Change (#80)
Browse files Browse the repository at this point in the history
* Update Snapshot Workflow and KCL Change

* fix workflow

* update grep

* In the realm of scripts and screens, adding a dash of mechanical dreams.

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
jgomez720 and github-actions[bot] committed Sep 13, 2024
1 parent 314951f commit caf6891
Show file tree
Hide file tree
Showing 38 changed files with 30,951 additions and 24,198 deletions.
18 changes: 15 additions & 3 deletions .github/workflows/output-from-kcl-samples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,24 @@ jobs:
fileName=$(basename "${file%.*}")
fileDir=$(dirname "$file")
echo "Processing $fileName..."
if [ -f "$fileDir/project.toml" ]; then
base_unit=$(grep '^base_unit' "$fileDir/project.toml" | cut -d '=' -f2 | tr -d ' "')
# If base_unit is blank, set it to "mm"
if [ -z "$base_unit" ]; then
base_unit="mm"
fi
else
echo "No project.toml found in $fileDir. Using default base_unit: mm"
base_unit="mm"
fi
# Take a snapshot
zoo kcl snapshot "$file" "./screenshots/$fileName.png"
zoo kcl snapshot --src-unit=$base_unit "$file" "./screenshots/$fileName.png"
# Try to export to STEP format
if zoo kcl export --output-format=step --src-unit=in "$file" "./step"; then
if zoo kcl export --output-format=step --src-unit=$base_unit "$file" "./step"; then
mv "./step/output.step" "./step/$fileName.step"
# Stabilize the date
sed -E -i 's/[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\.[0-9]+[0-9]+[0-9]\+[0-9]{2}:[0-9]{2}/1970-01-01T00:00:00.0+00:00/g' "./step/$fileName.step"
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ When you submit a PR to add or modify KCL samples, images and STEP files will be
[![bracket](screenshots/bracket.png)](./bracket/bracket.kcl)
#### [sheet-metal-bracket](./sheet-metal-bracket/sheet-metal-bracket.kcl) ([step](step/sheet-metal-bracket.step)) ([screenshot](screenshots/sheet-metal-bracket.png))
[![sheet-metal-bracket](screenshots/sheet-metal-bracket.png)](./sheet-metal-bracket/sheet-metal-bracket.kcl)
#### [french-press](./french-press/french-press.kcl) ([step](step/french-press.step)) ([screenshot](screenshots/french-press.png))
[![french-press](screenshots/french-press.png)](./french-press/french-press.kcl)
#### [washer](./washer/washer.kcl) ([step](step/washer.step)) ([screenshot](screenshots/washer.png))
[![washer](screenshots/washer.png)](./washer/washer.kcl)
#### [a-parametric-bearing-pillow-block](./a-parametric-bearing-pillow-block/a-parametric-bearing-pillow-block.kcl) ([step](step/a-parametric-bearing-pillow-block.step)) ([screenshot](screenshots/a-parametric-bearing-pillow-block.png))
Expand Down
33 changes: 17 additions & 16 deletions bracket/bracket.kcl
Original file line number Diff line number Diff line change
@@ -1,33 +1,34 @@
// Bracket
// This is a bracket that holds a shelf. It is made of aluminum and is designed to hold a force of 150 lbs. The bracket is 6 inches wide and the force is applied 6 inches from the wall. The bracket has a factor of safety of 2. The legs of the bracket are 5 inches and 8 inches long. The thickness of the bracket is calculated from the constrained provided. The inner and outer edges of the bend are filleted with a radius of 3/8 inch.

// Shelf Bracket
// This is a bracket that holds a shelf. It is made of aluminum and is designed to hold a force of 300 lbs. The bracket is 6 inches wide and the force is applied at the end of the shelf, 12 inches from the wall. The bracket has a factor of safety of 1.2. The legs of the bracket are 5 inches and 2 inches long. The thickness of the bracket is calculated from the constraints provided.

// Define constants
const sigmaAllow = 15000 // psi (6061-T6 aluminum)
const sigmaAllow = 35000 // psi (6061-T6 aluminum)
const width = 6 // inch
const p = 150 // Force on shelf - lbs
const distance = 6 // inches
const factorOfSafety = 2
const leg1Length = 5 // inches
const leg2Length = 2 // inches
const p = 300 // Force on shelf - lbs
const factorOfSafety = 1.2 // FOS of 1.2
const shelfMountL = 5 // inches
const wallMountL = 2 // inches
const shelfDepth = 12 // Shelf is 12 inches in depth from the wall
const moment = shelfDepth * p // assume the force is applied at the end of the shelf to be conservative (lb-in)

const filletRadius = .375 // inches
const extFilletRadius = .25 // inches
const mountingHoleDiameter = 0.5 // inches

// Calculate required thickness of bracket
const thickness = sqrt(distance * p * factorOfSafety * 6 / (sigmaAllow * width)) // in
const thickness = sqrt(moment * factorOfSafety * 6 / (sigmaAllow * width)) // this is the calculation of two brackets holding up the shelf (inches)

// Sketch the bracket body and fillet the inner and outer edges of the bend
const bracketLeg1Sketch = startSketchOn('XY')
|> startProfileAt([0, 0], %)
|> line([leg1Length-filletRadius, 0], %, $fillet1)
|> line([shelfMountL-filletRadius, 0], %, $fillet1)
|> line([0, width], %, $fillet2)
|> line([-leg1Length + filletRadius, 0], %)
|> line([-shelfMountL + filletRadius, 0], %)
|> close(%)
|> hole(circle([1, 1], mountingHoleDiameter/2, %), %)
|> hole(circle([leg1Length-1.5, width-1], mountingHoleDiameter/2, %), %)
|> hole(circle([shelfMountL-1.5, width-1], mountingHoleDiameter/2, %), %)
|> hole(circle([1, width-1], mountingHoleDiameter/2, %), %)
|> hole(circle([leg1Length-1.5, 1], mountingHoleDiameter/2, %), %)
|> hole(circle([shelfMountL-1.5, 1], mountingHoleDiameter/2, %), %)

// Extrude the leg 2 bracket sketch
const bracketLeg1Extrude = extrude(thickness, bracketLeg1Sketch)
Expand Down Expand Up @@ -72,7 +73,7 @@ const customPlane = {
const bracketLeg2Sketch = startSketchOn(customPlane)
|> startProfileAt([0, -filletRadius], %)
|> line([width, 0], %)
|> line([0, -leg2Length], %, $fillet3)
|> line([0, -wallMountL], %, $fillet3)
|> line([-width, 0], %, $fillet4)
|> close(%)
|> hole(circle([1, -1.5], mountingHoleDiameter / 2, %), %)
Expand All @@ -86,4 +87,4 @@ const bracketLeg2Extrude = extrude(-thickness, bracketLeg2Sketch)
getNextAdjacentEdge(fillet3),
getNextAdjacentEdge(fillet4)
],
}, %)
}, %)
Binary file modified screenshots/80-20-rail.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified screenshots/a-parametric-bearing-pillow-block.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified screenshots/ball-bearing.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified screenshots/bracket.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified screenshots/car-wheel.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified screenshots/flange-with-patterns.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified screenshots/flange-xy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added screenshots/french-press.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified screenshots/mounting-plate.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified screenshots/pipe-flange-assembly.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified screenshots/pipe.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified screenshots/poopy-shoe.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified screenshots/sheet-metal-bracket.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified screenshots/socket-head-cap-screw.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified screenshots/washer.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified screenshots/wheel-rotor.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit caf6891

Please sign in to comment.