From dc0cf461f6ad5d41ffa0b82c3bdd8a016c4f4f44 Mon Sep 17 00:00:00 2001 From: wes Date: Fri, 8 Nov 2024 11:21:36 -0500 Subject: [PATCH] curtain holder, formatting --- battery_cover.py | 32 ++++++++++++++------- curtain_holder.py | 57 ++++++++++++++++++++++++++++++++++++++ fan_control_box.py | 5 ++-- hair_dryer_holder.py | 16 ++++++++--- hexdriver_holder.py | 9 +++--- modified_enclosure_back.py | 17 ++++++++---- music_player_case.py | 8 ++++-- potentiometer_washer.py | 4 +-- screwdriver_holder.py | 16 +++++------ tongs_part.py | 6 ++-- vacuum_adapter.py | 12 +++++--- 11 files changed, 136 insertions(+), 46 deletions(-) create mode 100644 curtain_holder.py diff --git a/battery_cover.py b/battery_cover.py index f746545..f582623 100644 --- a/battery_cover.py +++ b/battery_cover.py @@ -14,8 +14,8 @@ from math import ceil, floor Workplane = cqmore.extend(Workplane) Workplane.addSvgPath = addSvgPath -side_notch_distance = 3.3 # how far from the main part to the side notch -side_notch_width = 4.0 # width of the side notch +side_notch_distance = 3.3 # how far from the main part to the side notch +side_notch_width = 4.0 # width of the side notch side_notch_thickness = 1.5 side_notch_height = 3 @@ -34,19 +34,31 @@ result = result.box(side_thickness, width, height) result = ( result.workplane(offset=-(width / 2) + side_width) - .move(0, -(width / 2) + (side_width/2) + tooth_dist_from_side) - .line(0, width - tooth_dist_from_side*2 - side_width, forConstruction=True) + .move(0, -(width / 2) + (side_width / 2) + tooth_dist_from_side) + .line(0, width - tooth_dist_from_side * 2 - side_width, forConstruction=True) .vertices() .box(side_thickness, side_width, side_height) ) result = ( - result - .workplane(offset=(height/2)) - .box(side_thickness, width + side_notch_distance*2 + side_notch_width*2, side_notch_distance) - .workplane(offset=(height/2) - side_notch_width + 0.5) - .move(0, -(width/2) - (side_notch_distance + side_notch_width/2) + side_notch_distance/2) - .line(0, width + side_notch_distance*2 + side_notch_width - side_notch_distance, forConstruction=True) + result.workplane(offset=(height / 2)) + .box( + side_thickness, + width + side_notch_distance * 2 + side_notch_width * 2, + side_notch_distance, + ) + .workplane(offset=(height / 2) - side_notch_width + 0.5) + .move( + 0, + -(width / 2) + - (side_notch_distance + side_notch_width / 2) + + side_notch_distance / 2, + ) + .line( + 0, + width + side_notch_distance * 2 + side_notch_width - side_notch_distance, + forConstruction=True, + ) .vertices() .box(side_notch_thickness, side_notch_width - 2, side_notch_height) ) diff --git a/curtain_holder.py b/curtain_holder.py new file mode 100644 index 0000000..086915a --- /dev/null +++ b/curtain_holder.py @@ -0,0 +1,57 @@ +from cadquery import exporters +from cq_warehouse.extensions import Workplane +import cadquery as cq + +result = Workplane() + +length = 27 +width = 10 +height = 30 + +rod_diameter = 11.0 +rod_height = 150 +rod_radius = rod_diameter / 2.0 + +female_hole_height = rod_height / 3.0 + +rod_female = Workplane() +rod_female = rod_female.cylinder(rod_height, rod_radius) + +rod_female = rod_female.workplane( + offset=(rod_height / 2.0) - female_hole_height / 2 +).cylinder(female_hole_height, (rod_radius / 2.0) + 0.15, combine="cut") + +rod_female = rod_female.workplane( + offset=-(rod_height / 2.0) - (female_hole_height / 2) + 20 +).cylinder(female_hole_height - 10, rod_radius / 2.0) + +rod_male = Workplane() +rod_male = rod_male.cylinder(rod_height, rod_radius) +rod_male = rod_male.workplane( + offset=(rod_height / 2.0) + (female_hole_height / 2) - 10 +).cylinder(female_hole_height - 10, rod_radius / 2.0) + +# l, w, h +result = result.box(length, width, height) + +result = ( + result.workplane(offset=-13) + .center(0, 0) + .box(length / 2, width, height + 7.73, combine="cut") +) +result = ( + result.workplane(offset=-30) + .center(10, 0) + .box(length / 2, width, height, combine="cut") +) +result = result.workplane(offset=-height / 2).center(-30, -2.5).box(20, 5, 5) +result = result.workplane(offset=-height / 2 + 10).center(-7.5, 0).box(5, 5, 20) + +cq.exporters.export(result, "/home/deck/model_files/curtain_holder.step") +cq.exporters.export(rod_female, "/home/deck/model_files/curtain_rod_female.step") +cq.exporters.export(rod_male, "/home/deck/model_files/curtain_rod_male.step") + +try: + show_object(result) +except NameError: + pass diff --git a/fan_control_box.py b/fan_control_box.py index 7d93e1a..53a0448 100644 --- a/fan_control_box.py +++ b/fan_control_box.py @@ -69,14 +69,13 @@ lower_box = ( ) lower_box = ( - lower_box - .workplane(offset=(pole_height/4)) + lower_box.workplane(offset=(pole_height / 4)) .rect( box_height - wall_thickness - pole_dist, box_width - wall_thickness - pole_dist ) .vertices() .cylinder(pole_height, 5) - .workplane(offset=(pole_height/4)) + .workplane(offset=(pole_height / 4)) .rect( box_height - wall_thickness - pole_dist, box_width - wall_thickness - pole_dist ) diff --git a/hair_dryer_holder.py b/hair_dryer_holder.py index 387980f..250c599 100644 --- a/hair_dryer_holder.py +++ b/hair_dryer_holder.py @@ -11,10 +11,18 @@ height = 80 # l, w, h result = result.box(length, width, height) -result = result.workplane(offset=-10).center(0, 0).box(length/2, width, height, combine="cut") -result = result.workplane(offset=-30).center(10, 0).box(length/2, width, height, combine="cut") -result = result.workplane(offset=-height/2).center(-30, -2.5).box(20, 5, 5) -result = result.workplane(offset=-height/2+10).center(-7.5, 0).box(5, 5, 20) +result = ( + result.workplane(offset=-10) + .center(0, 0) + .box(length / 2, width, height, combine="cut") +) +result = ( + result.workplane(offset=-30) + .center(10, 0) + .box(length / 2, width, height, combine="cut") +) +result = result.workplane(offset=-height / 2).center(-30, -2.5).box(20, 5, 5) +result = result.workplane(offset=-height / 2 + 10).center(-7.5, 0).box(5, 5, 20) cq.exporters.export(result, "/home/deck/model_files/hair_dryer_holder.step") diff --git a/hexdriver_holder.py b/hexdriver_holder.py index 01edcd4..24c3d69 100644 --- a/hexdriver_holder.py +++ b/hexdriver_holder.py @@ -40,16 +40,15 @@ result = ( .box(holder_length, shelf_width * 3, shelf_hold_height) ) -result = ( - result.workplane(offset=(shelf_hold_height / 2) - (holder_thickness / 2)) - .box(holder_length, shelf_width, shelf_hold_height, combine="cut") +result = result.workplane(offset=(shelf_hold_height / 2) - (holder_thickness / 2)).box( + holder_length, shelf_width, shelf_hold_height, combine="cut" ) -result = result.center(-holder_length/2-offset, 0) +result = result.center(-holder_length / 2 - offset, 0) for i in range(1, 10): result = result.center(offset, 0) - result = result.box(18, shelf_width*4, holder_width, combine="cut") + result = result.box(18, shelf_width * 4, holder_width, combine="cut") cq.exporters.export(result, "/home/deck/model_files/hexdriver_holder.step") diff --git a/modified_enclosure_back.py b/modified_enclosure_back.py index c9dc7a0..151df1f 100644 --- a/modified_enclosure_back.py +++ b/modified_enclosure_back.py @@ -38,22 +38,29 @@ magnet_holes_plane = ( .cylinder(12, 2) ) -cover_usb = Workplane("XZ").workplane(offset=-4.5).center(-4, height - 77).box(11, 5.3, 1.0) +cover_usb = ( + Workplane("XZ").workplane(offset=-4.5).center(-4, height - 77).box(11, 5.3, 1.0) +) result = cq.importers.importStep("/home/deck/Downloads/Backpanel_Part3.stp") +result_part1 = cq.importers.importStep("/home/deck/Downloads/Backpanel_Part1.stp") result = result.cut(holes_plane) -#result = result.union(magnet_holes_plane) +# result = result.union(magnet_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) +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.step") -cq.exporters.export(test_piece, "/home/deck/model_files/modified_backpanel_test_piece.step") +cq.exporters.export( + test_piece, "/home/deck/model_files/modified_backpanel_test_piece.step" +) try: - show_object(result) + show_object(result_part1) except NameError: pass diff --git a/music_player_case.py b/music_player_case.py index f523855..ca78c9c 100644 --- a/music_player_case.py +++ b/music_player_case.py @@ -74,8 +74,12 @@ usb_hole = ( result = result.cut(headphone_hole) result = result.cut(usb_hole) -top_back_text = Workplane("YX").workplane(offset=9).center(0, 5).text("If you find this", 3, 4) -back_text = Workplane("YX").workplane(offset=9).text("Email wes@wesk.tech for a reward", 3, 4) +top_back_text = ( + Workplane("YX").workplane(offset=9).center(0, 5).text("If you find this", 3, 4) +) +back_text = ( + Workplane("YX").workplane(offset=9).text("Email wes@wesk.tech for a reward", 3, 4) +) result = result.cut(top_back_text) result = result.cut(back_text) diff --git a/potentiometer_washer.py b/potentiometer_washer.py index d37aec8..58e8328 100644 --- a/potentiometer_washer.py +++ b/potentiometer_washer.py @@ -15,8 +15,8 @@ Workplane = cqmore.extend(Workplane) Workplane.addSvgPath = addSvgPath result = Workplane() -result = result.cylinder(0.4, 13/2) -result = result.cylinder(2, 6.65/2, combine="cut") +result = result.cylinder(0.4, 13 / 2) +result = result.cylinder(2, 6.65 / 2, combine="cut") cq.exporters.export(result, "/home/deck/model_files/potentiomer_washer.step") diff --git a/screwdriver_holder.py b/screwdriver_holder.py index 237846e..274abbf 100644 --- a/screwdriver_holder.py +++ b/screwdriver_holder.py @@ -35,25 +35,25 @@ result = result.box(holder_length, holder_width, holder_thickness) result = ( result.center(-((holder_length / 2) - hook_hole_diameter * 1.3), 0) - .workplane(offset=holder_thickness+2) + .workplane(offset=holder_thickness + 2) .line(hook_distance - hook_hole_radius * 2, 0, forConstruction=True) .vertices() .cylinder(hook_cylinder_length, hook_hole_radius) - .workplane(offset=holder_thickness+3) + .workplane(offset=holder_thickness + 3) .move(0, 5) .line(hook_distance - hook_hole_radius * 2, 0, forConstruction=True) .vertices() .box(hook_width, hook_height, hook_width) .workplane(offset=-holder_thickness - 2) - .move(holder_width, holder_width/2) - .line(holder_width*5, 0, forConstruction=True) + .move(holder_width, holder_width / 2) + .line(holder_width * 5, 0, forConstruction=True) .vertices() - .box(holder_width, shelf_hold_height, holder_thickness*4) + .box(holder_width, shelf_hold_height, holder_thickness * 4) .workplane(offset=-holder_thickness + 1) - .move(holder_width/2, holder_width/2 - 2) - .line(holder_width*5, 0, forConstruction=True) + .move(holder_width / 2, holder_width / 2 - 2) + .line(holder_width * 5, 0, forConstruction=True) .vertices() - .box(holder_width*2, shelf_hold_height, shelf_width, combine="cut") + .box(holder_width * 2, shelf_hold_height, shelf_width, combine="cut") ) cq.exporters.export(result, "/home/deck/model_files/screwdriver_holder.step") diff --git a/tongs_part.py b/tongs_part.py index f507bea..6cf6ee1 100644 --- a/tongs_part.py +++ b/tongs_part.py @@ -20,11 +20,11 @@ part_height = 24 result = Workplane() result = result.cylinder(part_height, part_radius) -result = result.workplane(offset=part_height/2).cylinder(2, part_radius + 1) +result = result.workplane(offset=part_height / 2).cylinder(2, part_radius + 1) end_piece = Workplane() -end_piece = end_piece.cylinder(2, part_radius*4) -end_piece = end_piece.cylinder(6, part_radius-0.3, combine="cut") +end_piece = end_piece.cylinder(2, part_radius * 4) +end_piece = end_piece.cylinder(6, part_radius - 0.3, combine="cut") cq.exporters.export(result, "/home/deck/model_files/tongs_part.step") cq.exporters.export(end_piece, "/home/deck/model_files/tongs_part_end_piece.step") diff --git a/vacuum_adapter.py b/vacuum_adapter.py index 9e2fc76..1be8e86 100644 --- a/vacuum_adapter.py +++ b/vacuum_adapter.py @@ -26,9 +26,9 @@ adapter_diameter = 30.3 adapter_radius = adapter_diameter / 2.0 adapter_height = 50 -adapter_thickness = 3 # how thick the side is +adapter_thickness = 3 # how thick the side is -end_part_height = 150 # how long the end part is +end_part_height = 150 # how long the end part is end_part_width = 10 side_cut = Workplane("ZX") @@ -48,9 +48,13 @@ side_cut = ( result = Workplane() result = result.cylinder(adapter_height, adapter_radius + adapter_thickness) -result = result.workplane(offset=5).cylinder(adapter_height, adapter_radius, combine="cut") +result = result.workplane(offset=5).cylinder( + adapter_height, adapter_radius, combine="cut" +) -result = result.workplane(offset=-adapter_height*1.9).box(end_part_width, end_part_width, end_part_height) +result = result.workplane(offset=-adapter_height * 1.9).box( + end_part_width, end_part_width, end_part_height +) result = result.workplane(offset=0).box(8, 8, 400, combine="cut") result = result.cut(side_cut)