Skip to content

Instantly share code, notes, and snippets.

@lf94
Created January 16, 2024 02:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lf94/11a057b992baf0f56f4afbcfaa52b4cb to your computer and use it in GitHub Desktop.
Save lf94/11a057b992baf0f56f4afbcfaa52b4cb to your computer and use it in GitHub Desktop.
import cadquery as cq
# Parameters for the bearing
outer_diameter = 22.0 # Outer diameter of the bearing
inner_diameter = 8.0 # Inner diameter of the bearing
width = 7.0 # Width of the bearing
ball_diameter = 4.0 # Diameter of the bearing balls
number_of_balls = 7 # Number of balls in the bearing
# Create the outer race
outer_race = (
cq.Workplane("XY")
.circle(outer_diameter / 2)
.circle((outer_diameter - width) / 2)
.extrude(width)
)
# Create the inner race
inner_race = (
cq.Workplane("XY")
.circle(inner_diameter / 2)
.circle((inner_diameter + width) / 2)
.extrude(width)
)
# Create the cage for the balls (simplified representation)
cage = (
cq.Workplane("XY")
.circle((inner_diameter + outer_diameter) / 4 + (ball_diameter / 2))
.circle((inner_diameter + outer_diameter) / 4 - (ball_diameter / 2))
.extrude(width)
)
# Create the balls
balls = (
cq.Workplane("XY")
.polarArray((outer_diameter + inner_diameter) / 4, 0, 360 / number_of_balls, number_of_balls, fill=False)
.circle(ball_diameter / 2)
.extrude(width)
)
# Create the assembly
bearing_assembly = outer_race.union(inner_race).cut(cage).union(balls)
# Export the result
cq.exporters.export(bearing_assembly, "/tmp/092ced95-cd02-4725-8552-4ca8f1d1f424.step")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment