Explorar el Código

add existing files

Silas Gruen hace 1 año
padre
commit
98c243094d

+ 4 - 0
README.md

@@ -0,0 +1,4 @@
+ # Cadquery Files
+ Repo for all .py files containing cadquery models (https://github.com/CadQuery/cadquery).
+ 
+ OCP viewer extension for VSCode recommended for install (https://marketplace.visualstudio.com/items?itemName=bernhard-42.ocp-cad-viewer) 

+ 62 - 0
mill/bltouch_holder.py

@@ -0,0 +1,62 @@
+import cadquery as cq
+from cadquery.occ_impl.exporters import *
+from ocp_vscode import show
+
+attach_hole_diam = 5.1
+attach_hole_dist = 50
+
+thick = 3
+flap_width = 15
+flap_len = attach_hole_dist + 2 * attach_hole_diam
+
+
+holder_width = 26.2
+holder_depth = 10.5 + thick
+
+bl_hole_diam = 3.85
+bl_hole_dist = 21.4 - bl_hole_diam
+
+flap = (
+    cq.Workplane("XY")
+    .workplane()
+    .rect(flap_len, flap_width)
+    .extrude(thick)
+)
+
+flap = (
+    flap.faces(">Z")
+    .workplane()
+    .center(attach_hole_dist/2, 0)
+    .circle(attach_hole_diam/2)
+    .center(-attach_hole_dist, 0)
+    .circle(attach_hole_diam/2)
+    .cutThruAll()
+    # .edges("|Z")
+    # .fillet(2)
+)
+angle = (
+    flap.faces(">X")
+    .workplane(centerOption="CenterOfBoundBox")
+    .center(0, -thick/2)
+    .rect(holder_width, holder_depth, centered=(True,False))
+    .extrude(thick)
+    .faces(">X")
+    .workplane(centerOption="CenterOfBoundBox")
+    .center(-bl_hole_dist/2, 0)
+    .circle(bl_hole_diam/2)
+    .center(bl_hole_dist,0)
+    .circle(bl_hole_diam/2)
+    .cutThruAll()
+    .edges("|X")
+    .fillet(1)
+    .faces("<X")
+    .fillet(1)
+)
+
+
+show(angle)
+
+# export the box as a STEP file
+with open("/home/sgruen/Dokumente/cadquery/bltouch_holder.step", "w") as fp:
+   cq.exporters.exportShape(angle, ExportTypes.STEP, fp)
+

+ 47 - 0
mill/endstop/endstop_plate.py

@@ -0,0 +1,47 @@
+import cadquery as cq
+from cadquery.occ_impl.exporters import *
+from ocp_vscode import show
+
+center_width = 18
+side_height = 14
+center_height = 30
+thickness = 4
+shift = 2
+center_hole_diam = 2.2
+center_hole_dist = 9.7
+center_hole_shift = center_width/2
+side_hole_diam = 3.1
+
+center = cq.Workplane("XY").box(center_width, center_height, thickness)
+side = (
+    center.
+    faces(">Y")
+    .workplane(origin=(0,0,shift))
+    .rect(center_width, thickness)
+    .extrude(side_height)
+)
+side_copy = side.mirror("XZ")
+result = center.union(side).union(side_copy)
+result = (
+    result.faces(">Z")
+    .workplane()
+    .rect(center_width/2,center_height+side_height, forConstruction=True)
+    .vertices()
+    .circle(side_hole_diam/2)
+    .cutThruAll()
+)
+
+result = (
+    result.faces("<Z")
+    .workplane()
+    .rect(center_hole_shift,center_hole_dist,forConstruction=True)
+    .vertices(">X")
+    .circle(center_hole_diam/2)
+    .cutThruAll()
+).chamfer(0.5)
+
+show(result)
+
+# export the box as a STEP file
+with open("/home/sgruen/Dokumente/cadquery/endstop_plate.step", "w") as fp:
+   cq.exporters.exportShape(result, ExportTypes.STEP, fp)

+ 65 - 0
mill/endstop/mill_endstop_holder.py

@@ -0,0 +1,65 @@
+import cadquery as cq
+from cadquery.occ_impl.exporters import *
+from ocp_vscode import show
+
+pipe_diam = 25.1
+clip_thickness = 5
+clip_gap = 1.5
+clip_height = 12
+clip_holes_diam = 4.1
+total_thickness = 15
+holder_height = 25
+
+
+# Create the ring by defining two concentric circles and extruding them
+clip = (
+    cq.Workplane("XY")  # Start in the XY plane
+    .circle(pipe_diam/2)
+    .circle(pipe_diam/2+clip_thickness)
+    .extrude(total_thickness)       # Extrude to the specified height
+)
+
+clip_with_holes = (
+    clip
+    .faces(">Z")
+    .workplane()
+    .rect(pipe_diam+(clip_thickness+clip_height)*2, clip_gap+clip_thickness*2)
+    .extrude(-total_thickness)
+    .faces(">Y")
+    .workplane(origin=(pipe_diam/2+clip_thickness+clip_height/2, 0, total_thickness/2))
+    .circle(clip_holes_diam/2)
+    .cutThruAll()
+    .faces(">Y")
+    .workplane(origin=(-(pipe_diam/2+clip_thickness+clip_height/2), 0, total_thickness/2))
+    .circle(clip_holes_diam/2)
+    .cutThruAll()
+)
+
+clip_with_ends = clip.union(
+    clip_with_holes
+)
+
+clip_with_gap = (
+    clip_with_ends
+    .faces(">Z")
+    .workplane(centerOption="CenterOfMass")
+    .rect(pipe_diam+(clip_thickness+clip_height)*2, clip_gap)
+    .cutThruAll()
+    .circle(pipe_diam/2)
+    .cutThruAll()
+)
+
+result = clip_with_gap.union(
+    clip_with_gap
+    .faces(">X")
+    .workplane(origin=(0, (clip_thickness + clip_gap)/2, total_thickness/2))
+    .rect(clip_thickness, total_thickness)
+    .extrude(holder_height)
+).fillet(1)
+
+show(result)
+
+
+# export the box as a STEP file
+with open("/home/sgruen/Dokumente/cadquery/mill-endstop.step", "w") as fp:
+   cq.exporters.exportShape(result, ExportTypes.STEP, fp)

+ 57 - 0
mill/endstop/mill_endstop_lever.py

@@ -0,0 +1,57 @@
+import cadquery as cq
+from cadquery.occ_impl.exporters import *
+from ocp_vscode import show
+
+hole_diam = 5
+hole_dist = 24.5
+bar_width = 8
+bar_thickness = 2.75
+height_padding = 2
+lever_length = 32
+lever_max_thickness = 8
+
+
+
+bar_height = hole_dist + hole_diam + 2*height_padding
+clip = (
+    cq.Workplane("XY")  # Start in the XY plane
+    .box(bar_width, bar_height,bar_thickness)
+    .edges("|Z and >Y or |Z and >X")
+    .fillet(2)
+    .faces(">Z")
+    .workplane()
+    .rect(0,hole_dist,forConstruction=True)
+    .vertices(">X")
+    .circle(hole_diam/2)
+    .cutThruAll()
+)
+
+upper_lever = cq.Sketch().trapezoid(bar_thickness, lever_length,100, angle=90).vertices("<X").fillet(1)
+upper_thick_lever = upper_lever.moved(z=-bar_thickness/2)
+bottom = cq.Sketch().trapezoid(bar_thickness, lever_length/4,100, angle=90).vertices("<X").fillet(1).moved(x = 3*lever_length/8, z=(height_padding+hole_diam))
+# extr_trapezoid = cq.Workplane().placeSketch(upper_lever, lower_lever).loft()
+
+lever = (
+   clip.faces("<Y")
+   .workplane(
+        offset=-(height_padding+hole_diam),
+        origin=(-(lever_length/2 + bar_width/2), 0, 0)
+    )
+   .placeSketch(upper_lever, bottom).loft()
+)
+lever_thick = (
+   clip.faces("<Y")
+   .workplane(
+        offset=-(height_padding+hole_diam),
+        origin=(-(lever_length/2 + bar_width/2), 0, 0)
+    )
+   .placeSketch(upper_lever, upper_thick_lever).loft()
+)
+
+result = clip.union(lever).union(lever_thick)
+show(result)
+
+
+# export the box as a STEP file
+with open("/home/sgruen/Dokumente/cadquery/mill-endstop-lever.step", "w") as fp:
+   cq.exporters.exportShape(result, ExportTypes.STEP, fp)

+ 37 - 0
mill/mill_cap.py

@@ -0,0 +1,37 @@
+import cadquery as cq
+from cadquery.occ_impl.exporters import *
+from ocp_vscode import show
+
+outer_diam = 25
+inner_diam = 20
+outer_height = 2
+inner_height = 15
+inner_thick = 1.5
+cut_width = 2
+
+result = (
+    cq.Workplane("XY")
+    .workplane()
+    .circle(outer_diam/2)
+    .extrude(outer_height)
+    .faces(">Z")
+    .workplane()
+    .circle(inner_diam/2)
+    .circle(inner_diam/2-inner_thick)
+    .extrude(inner_height)
+    .faces("<Z")
+    .fillet(1.5)
+    .faces(">Z")
+    .edges()[0]
+    .chamfer(7.5,1.2)
+    .faces(">Z")
+    .workplane()
+    .rect(inner_diam, cut_width)
+    .rect(cut_width, inner_diam)
+    .cutBlind(-inner_height)
+)
+show(result)
+
+# export the box as a STEP file
+with open("/home/sgruen/Dokumente/cadquery/mill_cap.step", "w") as fp:
+   cq.exporters.exportShape(result, ExportTypes.STEP, fp)

+ 28 - 0
mill/vise_angle.py

@@ -0,0 +1,28 @@
+import cadquery as cq
+from cadquery.occ_impl.exporters import *
+from ocp_vscode import show
+
+width = 60
+depth = 159
+thick = 2
+angle_deg = 1
+
+hole_length = 79
+hole_width = 43.5
+hole_diam = 6
+
+result = (
+    cq.Workplane("XY")
+    .workplane(centerOption="CenterOfBoundBox")
+    .rect(depth,width)
+    .workplane(offset=thick)
+    .transformed(rotate=(0, angle_deg, 0)) 
+    .rect(depth,width)
+    .loft()
+)
+result = result.faces("<Z").workplane().rect(hole_length, hole_width,forConstruction=True).vertices().circle(hole_diam/2).cutThruAll()
+show(result)
+
+# export the box as a STEP file
+with open("/home/sgruen/Dokumente/cadquery/vise_angle.step", "w") as fp:
+   cq.exporters.exportShape(result, ExportTypes.STEP, fp)

+ 60 - 0
mill/vise_segment.py

@@ -0,0 +1,60 @@
+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)

+ 222 - 0
pi_housing/pi_cam_housing.py

@@ -0,0 +1,222 @@
+import cadquery as cq
+from cadquery.occ_impl.exporters import *
+from ocp_vscode import show, show_object
+
+
+###### Angle param #####
+hole_diam = 5.1
+hole_dist = 50
+bar_width = 20
+two_bar_width = hole_dist + bar_width
+
+board_length = 64.5
+board_width = 28.7
+board_thick = 0.7
+
+lid = cq.importers.importStep(r"mill/Pi_housing/lid_smaller_holes.step")
+base = cq.importers.importStep(r"mill/Pi_housing/base_smaller_holes.step")
+
+slit_width = 3
+slit_offset = 1
+
+angle_thick = 3
+angle_width = 10
+angle_length = 30
+flap_length = 15
+shift = 5
+
+###### BL Touch Holder param #####
+extension_len = 25
+bl_holder_width = 26.2
+bl_holder_depth = 10.5 + angle_thick
+
+bl_hole_diam = 3.85
+bl_hole_dist = 21.4 - bl_hole_diam
+
+###### Cam Holder param #####
+lens_diam = 7.5
+lens_holder_width = 8.5
+lens_holder_thick = 2.9
+
+cam_dist = 30
+cam_angle = 45
+
+holder_length = 60
+holder_length_offset = 20
+holder_width = 12
+holder_thick = angle_thick
+
+edge_length = 10
+
+case_thick = 2
+case_air = 0.2
+cable_thick = 1
+case_fillet = 8
+
+holder_x = hole_dist/2-holder_length_offset
+holder_y = -10
+
+
+
+###### Angle #####
+connector = (
+    base.faces(">Z").workplane(origin=(-hole_dist/2,0,shift))
+    .box(angle_width, angle_length, angle_thick, (True, False, False), combine=False)
+)
+connector = connector.faces(">Z").workplane().center(0, angle_width/2).circle(slit_width/2).cutThruAll()
+connector_shift = connector.translate((hole_dist+slit_offset,0,0))
+connector_bar = (
+    connector.faces(">X")
+    .workplane(centerOption="CenterOfBoundBox")
+    .center((angle_length-angle_width)/2,0)
+    .rect(angle_width, angle_thick, centered=(True, True))
+    .extrude(hole_dist)
+)
+connector_wide = (
+    connector.union(connector_bar).union(connector_shift)
+    .edges("<Y and |Z")
+    .fillet(4)
+)
+connector_wide = connector_wide.faces("|Y")[3].edges("|Z").fillet(5)
+
+actual_flap_length = flap_length + angle_thick
+flap = (
+    connector_wide.faces(">Y")
+    .workplane(centerOption="CenterOfBoundBox")
+    .center(0,-angle_thick/2)
+    .rect(hole_dist+angle_width+slit_offset,actual_flap_length, centered=(True,False))
+    .extrude(angle_thick, combine=False)
+)
+
+flap = (
+    flap.faces("<Y")
+    .workplane()
+    .center(hole_dist/2, actual_flap_length - hole_diam)
+    .circle(hole_diam/2)
+    .center(-hole_dist, 0)
+    .circle(hole_diam/2)
+    .cutThruAll()
+)
+
+
+flap = (
+   flap.faces(">X")
+   .workplane(centerOption="CenterOfBoundBox")
+   .rect(angle_thick, flap_length+angle_thick)
+   .extrude(extension_len)
+)
+
+holder_shift = bl_holder_width - flap_length - angle_thick
+bl_holder = (
+    flap.faces(">X")
+    .workplane(centerOption="CenterOfBoundBox")
+    .center(-angle_thick/2, holder_shift/2)
+    .rect(bl_holder_depth, bl_holder_width, centered=(False,True))
+    .extrude(angle_thick)
+    .faces(">X")
+    .workplane(centerOption="CenterOfBoundBox")
+    .center(0, -bl_hole_dist/2)
+    .circle(bl_hole_diam/2)
+    .center(0, bl_hole_dist)
+    .circle(bl_hole_diam/2)
+    .cutThruAll()
+    .faces("+Z")[0]
+    .edges(">X")
+    .chamfer(holder_shift-0.1, holder_shift*2)
+    .faces("<X")
+    .edges(">Z")
+    .fillet(3)
+    .faces(">Y")
+    .edges("|X")
+    .fillet(5)
+)
+
+angle = connector_wide.union(bl_holder)
+
+############
+
+
+###### CamHolder #####
+
+holder = (
+    base.faces(">Z").workplane()
+    .center(holder_x, holder_y)
+    .box(holder_length, holder_width, holder_thick, (False, True, False), combine=False)
+    .edges("|Z and <X and <Y ")
+    .fillet(4)
+)
+case_dim_x = lens_holder_width + case_thick + case_air
+case_dim_z = lens_holder_thick+case_air+case_thick
+case_dim_y = case_dim_x + holder_width/2 - holder_y
+cam_case = (
+    holder.faces(">Z").workplane()
+    .center(holder_length, -holder_width/2)
+    .box(case_dim_x*2, case_dim_y, case_dim_z, combine=False, centered=(True,False,False))
+)
+indside_width = lens_holder_width+case_air
+cam_case_inside = (
+    cam_case.faces(">Z").workplane(invert=True)
+    .center(-case_dim_x/2, -case_dim_y + case_dim_x/2)
+    .box(indside_width, indside_width, lens_holder_thick+case_air, combine=False, centered=(True,True,False))
+    .center(-1,0)
+    .box(indside_width, indside_width, cable_thick+case_air, centered=(True,True,False))
+) # Lens holder hole
+cam_case = (
+    cam_case.faces("<Z").workplane()
+    .center(-case_dim_x/2, -(case_dim_y - case_dim_x/2))
+    .cskHole(lens_diam, lens_diam*1.8, 120)
+) # Lens hole
+cam_case = cam_case.cut(cam_case_inside).edges("|Z and <X and <Y").fillet(case_fillet)
+cam_case = (
+    cam_case
+    .rotateAboutCenter((0,1,0), 270-cam_angle)
+    .translate((2,0,-6.5))
+)
+
+holder = (
+    holder.faces(">Y").workplane()
+    .rect(-holder_width,holder_thick, centered=(False,False))
+    .extrude(edge_length)
+    .faces(">Y")
+    .edges("|Z")
+    .fillet(5)
+)
+
+holder = (
+    holder.faces(">Z")
+    .workplane()
+    .center(holder_width/2, edge_length/2)
+    .circle(slit_width/2)
+    .cutThruAll()
+    .center(angle_length/2-slit_width/2, -edge_length)
+    .circle(slit_width/2)
+    .cutThruAll()
+)
+
+cam_case_lid = (
+    cam_case.faces(">(-1, 0, -1)").workplane(centerOption="CenterOfBoundBox")
+    .box(case_dim_y, case_dim_x*2, case_thick, combine=False, centered=(True, True, False))
+    .edges(">(1, -1, -1)").fillet(case_fillet)
+)
+cam_case_lid = cam_case_lid.cut(holder)
+
+holder = holder.union(cam_case)
+
+
+############
+
+show_object(lid)
+show_object(base)
+show_object(angle)
+show_object(holder)
+show_object(cam_case_lid)
+
+# export the box as a STEP file
+with open(r"mill/Pi_housing/pi_angle.step", "w") as fp:
+   cq.exporters.exportShape(angle, ExportTypes.STEP, fp)
+
+with open(r"mill/Pi_housing/cam_holder.step", "w") as fp:
+   cq.exporters.exportShape(holder, ExportTypes.STEP, fp)
+
+with open(r"mill/Pi_housing/cam_case_lid.step", "w") as fp:
+   cq.exporters.exportShape(cam_case_lid, ExportTypes.STEP, fp)

+ 26 - 0
segment_gehauese/bodenplatte.py

@@ -0,0 +1,26 @@
+import cadquery as cq
+from cadquery.occ_impl.exporters import ExportTypes
+
+from ocp_vscode import show, show_object
+
+
+###### Angle param #####
+hole_diam = 5.1
+hole_dist = 50
+bar_width = 20
+two_bar_width = hole_dist + bar_width
+
+board_length = 64.5
+board_width = 28.7
+board_thick = 0.7
+
+# front = cq.importers.importStep(r"/home/sgruen/Dokumente/bodenplatte/Frontplate4x16SegmentVent_V003 (Solid)001.step")
+plate_2d = cq.importers.importDXF(r"/home/sgruen/Dokumente/bodenplatte/bodenplatte.dxf")
+plate = plate_2d.extrude(4)
+
+############
+
+show_object(plate)
+
+with open(r"/home/sgruen/Dokumente/bodenplatte/bodenplatte_8der_4mm.step", "w") as fp:
+   cq.exporters.exportShape(plate, ExportTypes.STEP, fp)

+ 60 - 0
segment_gehauese/spacer.py

@@ -0,0 +1,60 @@
+import cadquery as cq
+from cadquery.occ_impl.exporters import ExportTypes
+
+from ocp_vscode import show, show_object
+
+
+###### Angle param #####
+a_thick = 1.7
+a_diam = 3.2
+a_gap_width = 1
+overhang_a_width = a_gap_width /2 * 0.9
+overhang_a_height = 3
+
+b_thick = 4.2
+b_diam = 2.8
+b_gap_width = a_gap_width
+overhang_b_width = b_gap_width /2 * 0.98
+overhang_b_height = overhang_a_height
+
+thick_eps = 0.1
+space_height = 2.5
+space_diam = 7
+overhang_top = 0.5
+
+print_height = 3
+
+spacer = cq.Workplane("XY").cylinder(space_height, space_diam/2)
+
+clip_a = (
+   spacer.faces(">Z").workplane()
+   .circle(a_diam/2-thick_eps).extrude(a_thick, combine=False)
+   .faces(">Z").workplane()
+   .circle(a_diam/2+overhang_a_width).workplane(offset=overhang_a_height+thick_eps)
+   .circle(overhang_top).loft()
+   .faces(">Z").workplane()
+   .rect(a_gap_width, 100)
+   .cutThruAll()
+)
+
+clip_b = (
+   spacer.faces("<Z").workplane()
+   .circle(b_diam/2-thick_eps).extrude(b_thick, combine=False)
+   .faces("<Z").workplane()
+   .circle(b_diam/2+overhang_b_width).workplane(offset=overhang_b_height+thick_eps)
+   .circle(overhang_top).loft()
+   .faces("<Z").workplane()
+   .rect(b_gap_width, 100)
+   .cutThruAll()
+)
+
+spacer = spacer.union(clip_a).union(clip_b)
+spacer_cut = spacer.cut(cq.Workplane("XY").box(100, print_height, 100))  
+spacer = spacer.cut(spacer_cut)
+
+############
+
+show_object(spacer)
+
+with open(r"/home/sgruen/Dokumente/bodenplatte/spacer.step", "w") as fp:
+   cq.exporters.exportShape(spacer, ExportTypes.STEP, fp)