You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

118 lines
3.0 KiB

from cadquery import exporters
from cq_warehouse.extensions import Workplane
from cq_warehouse.fastener import *
from cq_warehouse.thread import *
from cqmore.curve import archimedeanSpiral, circle
from cqmore.polygon import regularPolygon, star
from cqmore.polyhedron import polarZonohedra, Polyhedron, superellipsoid
from svg_path import addSvgPath
from svgpathtools import svg2paths
import cadquery as cq
import cqmore
from math import ceil, floor
Workplane = cqmore.extend(Workplane)
Workplane.addSvgPath = addSvgPath
screw_simple = False # Controls whether to not actually make the screw threads, saves time running it for testing
cable_diameter = 5.6
cable_radius = cable_diameter / 2.0
screw_length = 10
power_cable_screw = ButtonHeadScrew(
size="M3-0.5",
fastener_type="iso7380_1",
length=screw_length * MM,
simple=screw_simple,
)
width = 154
height = 130
poop_chute_dist_from_side = 59
cable_gripper = (
Workplane("XY").cylinder(3, 11.2 / 2.0).cylinder(4, cable_radius, combine="cut")
)
cable_gripper_split = (
cable_gripper.workplane().move(-(11.2 / 2.0), 0).box(11.2, 11.2, 4, combine="cut")
)
holes_plane = (
Workplane("XZ")
.workplane(offset=-2)
.center(20, height - 75)
.cylinder(8, 17 / 2)
.workplane(offset=-7)
.center(0, height - 165)
.circle(11.5 / 2.0)
.extrude(20)
)
hole_extruded_plane = (
Workplane("XZ")
.workplane(offset=-2)
.center(0, height - 110)
.move(20, 0)
.circle(11.5 / 1.4)
.extrude(-5)
)
cover_usb = (
Workplane("XZ").workplane(offset=-4.5).center(-4, height - 25).box(11, 5.3, 1.0)
)
result = cq.importers.importStep("/home/deck/Downloads/Backpanel_Part3.stp")
result = result.union(hole_extruded_plane)
result = result.cut(holes_plane)
result = result.union(cover_usb)
# magnet distance should be 90 mm apart
test_piece = (
Workplane().workplane(offset=110).center(70, 0).box(80, 4, 60).cut(holes_plane)
)
cq.exporters.export(result, "/home/deck/model_files/modified_backpanel_part_3.stl")
cq.exporters.export(
test_piece, "/home/deck/model_files/modified_backpanel_test_piece.stl"
)
result_part1 = cq.importers.importStep("/home/deck/Downloads/Backpanel_Part1.stp")
magnet_diameter = 6.1
magnet_radius = magnet_diameter / 2.0
poop_chute_dist_from_bottom = (
14.8 # how far the poop chute is from the bottom of its piece
)
magnet_holes_plane = (
Workplane("XZ")
.center(
poop_chute_dist_from_side + 8,
-(poop_chute_dist_from_bottom) - (24 * 3 - (magnet_radius * 3)),
)
.rect(24, 24, forConstruction=True)
.vertices()
.cylinder(5, magnet_radius)
.center(0, 24)
.rect(24, 24, forConstruction=True)
.vertices()
.cylinder(5, magnet_radius)
)
result_part1 = result_part1.cut(magnet_holes_plane)
cq.exporters.export(
result_part1, "/home/deck/model_files/modified_backpanel_part_1.stl"
)
cq.exporters.export(cable_gripper_split, "/home/deck/model_files/cable_gripper.stl")
try:
show_object(cable_gripper_split)
except NameError:
pass