| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- import cadquery as cq
- from cadquery.occ_impl.exporters import *
- from cadquery.occ_impl.shapes import intersect
- from ocp_vscode import show
- import math
- result_depth = 65
- base_depth = 500
- thick = 4
- height_rips = 8.7
- width_rips = 5
- # dist_rips = 17,2
- total_dist_rips = 170
- angle_deg = 1
- num_rips = 11
- angle = -30
- width_base = total_dist_rips + width_rips
- spacing = total_dist_rips / (num_rips - 1) if num_rips > 1 else 0
- hole_diam = 6
- base = (
- cq.Workplane("XY")
- .rect(width_base, base_depth)
- .extrude(thick)
- )
- boxes_locations = []
- limit_lo = math.floor(num_rips/2)
- limit_hi = math.ceil(num_rips/2)
- for i in range(-limit_lo, limit_hi):
- boxes_locations.append((i * spacing, 0))
- boxes = (
- base.faces(">Z")
- .workplane()
- .pushPoints(boxes_locations)
- .eachpoint(
- lambda loc: (
- cq.Workplane()
- .rect(width_rips, base_depth)
- .extrude(height_rips)
- .val()
- .located(loc)
- )
- )
- )
- result = base.union(boxes).rotateAboutCenter((0,0,1), angle)
- cutout = (
- result.workplane(centerOption="CenterOfBoundBox")
- .box(base_depth, result_depth, thick+height_rips, combine=False)
- )
- cutted_res = cutout * result
- show(cutted_res)
- # export the box as a STEP file
- with open("/home/sgruen/Dokumente/cadquery/vise_segment_base.step", "w") as fp:
- cq.exporters.exportShape(cutted_res, ExportTypes.STEP, fp)
|