Skip to content

Commit

Permalink
Make 3D models compatible with latest CadQuery
Browse files Browse the repository at this point in the history
  • Loading branch information
Peque committed Oct 6, 2021
1 parent 9a52a99 commit a6e67ae
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 32 deletions.
52 changes: 35 additions & 17 deletions 3d/mount.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,15 @@


def circle_points(number, circle, shift=0):
radius = circle / 2.
radius = circle / 2.0
step = 360 / number
points = [(radius * sin(radians(i * step + shift)),
radius * cos(radians(i * step + shift)))
for i in range(number)]
points = [
(
radius * sin(radians(i * step + shift)),
radius * cos(radians(i * step + shift)),
)
for i in range(number)
]
return points


Expand Down Expand Up @@ -44,29 +48,43 @@ def circle_points(number, circle, shift=0):


# Basic mount structure
mount = cadquery.Workplane('XY').box(MOUNT_WIDTH, MOUNT_HEIGHT, MOUNT_THICK)
mount = cadquery.Workplane("XY").box(MOUNT_WIDTH, MOUNT_HEIGHT, MOUNT_THICK)

# Base screws
mount = mount.faces('<Y').workplane()\
.pushPoints([(-SCREW_SPACE / 2., 0), (SCREW_SPACE / 2., 0)])\
mount = (
mount.faces("<Y")
.workplane()
.pushPoints([(-SCREW_SPACE / 2.0, 0), (SCREW_SPACE / 2.0, 0)])
.hole(SCREW_DIAMETER)
)

# Motor holes
miniholes = circle_points(number=6, circle=MOUNT_MINIHOLES_CIRCLE)
mount = mount.faces('<Z').workplane()\
.pushPoints(miniholes)\
mount = (
mount.faces("<Z")
.workplane(centerOption="CenterOfMass")
.pushPoints(miniholes)
.hole(diameter=MOUNT_MINIHOLES_DIAMETER)
mount = mount.faces('>Z').workplane().cboreHole(
MOTOR_HOLE_DIAMETER,
MOTOR_DIAMETER + 1,
MOUNT_THICK - MOTOR_MOUNT_THICK)
)
mount = (
mount.faces(">Z")
.workplane()
.cboreHole(
MOTOR_HOLE_DIAMETER,
MOTOR_DIAMETER + 1,
MOUNT_THICK - MOTOR_MOUNT_THICK,
)
)

# Axis
axis_shift = (MODULE * (Z_PINION + Z_GEAR)) / 2.
axis_shift = (MODULE * (Z_PINION + Z_GEAR)) / 2.0
axis_shift *= cos(asin(MOTOR_SHIFT / axis_shift))
mount = mount.faces('<Z').workplane()\
.pushPoints([(axis_shift, -MOTOR_SHIFT), (-axis_shift, -MOTOR_SHIFT)])\
mount = (
mount.faces("<Z")
.workplane()
.pushPoints([(axis_shift, -MOTOR_SHIFT), (-axis_shift, -MOTOR_SHIFT)])
.hole(AXIS_DIAMETER)
)

# Fillet
mount = mount.edges('|Z').fillet(MOUNT_FILLET)
mount = mount.edges("|Z").fillet(MOUNT_FILLET)
39 changes: 25 additions & 14 deletions 3d/rim.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
import cadquery


REEL_D0 = 19.
REEL_H0 = 5.
REEL_D0 = 19.0
REEL_H0 = 5.0

REEL_D1 = 14.8
REEL_H1 = 3.
REEL_H1 = 3.0

BEARING_D = 6.2

Expand All @@ -21,17 +21,28 @@


# Rim body
rim = cadquery.Workplane('XY')\
.circle(radius=REEL_D0 / 2.).extrude(distance=REEL_H0)\
.faces('>Z').workplane()\
.circle(radius=REEL_D1 / 2.).extrude(distance=REEL_H1)\
.faces('>Z').workplane()\
rim = (
cadquery.Workplane("XY")
.circle(radius=REEL_D0 / 2.0)
.extrude(distance=REEL_H0)
.faces(">Z")
.workplane()
.circle(radius=REEL_D1 / 2.0)
.extrude(distance=REEL_H1)
.faces(">Z")
.workplane()
.hole(diameter=BEARING_D)
)

# Mini-holes
minihole_position = (REEL_D1 + BEARING_D) / 4.
miniholes = [(minihole_position * sin(radians(i * 360. / MINIHOLES)),
minihole_position * cos(radians(i * 360. / MINIHOLES)))
for i in range(MINIHOLES)]
rim = rim.faces('>Z').workplane()\
.pushPoints(miniholes).hole(diameter=MINIHOLE_D)
minihole_position = (REEL_D1 + BEARING_D) / 4.0
miniholes = [
(
minihole_position * sin(radians(i * 360.0 / MINIHOLES)),
minihole_position * cos(radians(i * 360.0 / MINIHOLES)),
)
for i in range(MINIHOLES)
]
rim = (
rim.faces(">Z").workplane().pushPoints(miniholes).hole(diameter=MINIHOLE_D)
)
3 changes: 2 additions & 1 deletion environment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ channels:
- cadquery
dependencies:
- python=3.6
- cadquery=2
- cadquery=2.1
- pip
- pip:
- bokeh
Expand All @@ -27,6 +27,7 @@ dependencies:
# Test
- pytest
# Lint
- black
- flake8
- flake8-quotes
# Documentation
Expand Down
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[tool.black]
line-length = 79

0 comments on commit a6e67ae

Please sign in to comment.