Prechádzať zdrojové kódy

improve spacer cutout

Silas Gruen 1 rok pred
rodič
commit
d9d295f621
1 zmenil súbory, kde vykonal 15 pridanie a 5 odobranie
  1. 15 5
      segment_gehauese/spacer.py

+ 15 - 5
segment_gehauese/spacer.py

@@ -2,11 +2,12 @@ import cadquery as cq
 from cadquery.occ_impl.exporters import ExportTypes
 
 from ocp_vscode import show, show_object
+import math
 
 
 ###### Parameter #####
 a_thick = 1.7
-a_diam = 3.2
+a_diam = 2.5
 a_gap_width = 1
 overhang_a_width = a_gap_width /2 * 0.9
 overhang_a_height = 3
@@ -22,7 +23,8 @@ space_height = 4
 space_diam = 7
 overhang_top = 0.5
 
-print_height = 2.8
+cut_height = 2.8 # use this for easier printing
+cut_center = False  # if false, cut is at the edge of smallest diameter of the spacer
 
 spacer = cq.Workplane("XY").cylinder(space_height, space_diam/2)
 
@@ -49,12 +51,20 @@ clip_b = (
 )
 
 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)
+
+if cut_height > 0:
+   if cut_center:
+      spacer_cut = spacer.cut(cq.Workplane("XY").box(100, cut_height, 100))
+   else:
+      min_diam = min(a_diam, b_diam) - 2*thick_eps
+      min_gap_width = min(a_gap_width, b_gap_width)
+      center_to_min_edge = math.sqrt(min_diam**2 - (min_gap_width)**2)/2
+      spacer_cut = spacer.cut(cq.Workplane("XY").box(100, cut_height, 100, centered=(True, False, True)).translate((0, -center_to_min_edge, 0)))
+   spacer = spacer.cut(spacer_cut)
 
 ############
 
 show_object(spacer)
 
-with open(r"/home/sgruen/Dokumente/bodenplatte/spacer.step", "w") as fp:
+with open(r"/home/sgruen/Dokumente/3D_prints/Schrankbau/bodenplatte/spacer_2.5.step", "w") as fp:
    cq.exporters.exportShape(spacer, ExportTypes.STEP, fp)