cadquery/octoprint-arm/modelo.py
2022-07-22 09:52:21 -03:00

50 lines
1.3 KiB
Python

import cadquery2 as cq
from cadquery2 import exporters
# camera hinge dimensions
inner_camera_hinge = 4.2 / 2
outer_camera_hinge = 8.5 / 2
camera_hinge_width = 15
# tripod hinge dimensions
inner_tripod_hinge = 7.5 / 2
outer_tripod_hinge = 17.5 / 2
tripod_hinge_width = 5.5
camera_hinge_shape = (
cq.Sketch().circle(outer_camera_hinge).circle(inner_camera_hinge, mode="s")
)
tripod_hinge_shape = (
cq.Sketch().circle(outer_tripod_hinge).circle(inner_tripod_hinge, mode="s")
)
arm_width = min(tripod_hinge_width, camera_hinge_width)
arm_length = 75
camera_arm = (
cq.Workplane("XY")
.rect(arm_width, arm_width)
.extrude(arm_length)
.edges("|Z or <Z or >Z")
.fillet(0.25)
.faces(">Y")
.tag("side")
.workplane(
centerOption="CenterOfBoundBox", offset=(camera_hinge_width - arm_width) / 2
)
.center(0, arm_length / 2 + (outer_camera_hinge - inner_camera_hinge))
.placeSketch(camera_hinge_shape)
.extrude(-camera_hinge_width)
.center(0, -(arm_length + outer_tripod_hinge))
# Undo previous offset + new offset
.workplane(
offset=-(camera_hinge_width - arm_width - tripod_hinge_width + arm_width) / 2
)
.placeSketch(tripod_hinge_shape)
.extrude(-tripod_hinge_width)
)
exporters.export(camera_arm, "camera_arm.stl")