Compare commits

...

13 Commits

3 changed files with 29287 additions and 48 deletions

29160
20-2040.dxf Normal file

File diff suppressed because it is too large Load Diff

View File

@ -13,14 +13,19 @@ m3_head_depth= 3
m3_passthrough= 3.5
# Fastener dimensions
fastener_width= 11
fastener_width= 11.5
fastener_height= 3.5
fastener_length= 20
fastener_h_spacing= .2
fastener_gap= .2
hex_diameter= 10
hex_depth= 4
m5_passthrough= 5.5
# NEMA 17 stepper motor
stepper_motor_size= 42.0
stepper_hole_width= 31.0
stepper_mount_dia= 22.5
# Case
part_thinkness= 20
@ -28,16 +33,17 @@ outer_fillets= 2.5
slant_degree= 15.0
wall_width= 1.6
loop_width= wall_width
loop_angle= 40
loop_angle= 36
rod_diameter= 15.2
offset= 9
tab_height= 6
tab_width= 25
lid_stepper_hole= 5.5
# Gears
mod= 0.8
gear_gap= 0.2
gear_offset= 0.5
gear_offset= 0.2
large_gear_diameter= 8.5
gear_thinkness= 10
sg_teeth= 11
@ -45,19 +51,21 @@ sg_teeth= 11
# Other
mount_gap= 2
support_radius= 11/2
end_y= -4.3
step_dep= 0.4
hack_num= 0.000001
# Calculated values
fastener_hole_depth = tab_height-2
lid_thicknesss = (part_thinkness-gear_thinkness)/2
gap = stepper_motor_size * math.sin(math.radians(slant_degree)) / math.sin(math.radians(90-slant_degree))
width = math.sqrt(gap**2 + stepper_motor_size**2 - 2*gap*stepper_motor_size*math.cos(math.radians(90)))
end_x=gap+stepper_motor_size-5
end_y=-4.3
outer_ring_diameter=rod_diameter+2*loop_width
center_x=end_x-math.cos(math.radians(loop_angle))*outer_ring_diameter/2
center_y=end_y-math.sin(math.radians(loop_angle))*outer_ring_diameter/2
end_x = gap+stepper_motor_size-5
outer_ring_diameter = rod_diameter+2*loop_width
center_x = end_x-math.cos(math.radians(loop_angle))*outer_ring_diameter/2
center_y = end_y-math.sin(math.radians(loop_angle))*outer_ring_diameter/2
# Stepper motor mount points
stepper_hole_radius=stepper_hole_width/2*math.sqrt(2)
stepper_hole_radius = stepper_hole_width/2*math.sqrt(2)
stepper_center = cq.Workplane('XY').lineTo(0, offset)\
.polarLine(stepper_motor_size/2, 90-slant_degree)\
.polarLine(stepper_motor_size/2, -slant_degree)\
@ -71,9 +79,10 @@ b = e[1] - slope*e[0]
support_y = end[1]-support_radius
support_x = (support_y-b)/slope
lg_x=support_x-stepper_center[0]
lg_y=support_y-stepper_center[1]
lg_radius = (math.sqrt(lg_x**2 + lg_y**2)-sg_teeth*mod/2)
lg_x = support_x-stepper_center[0]
lg_y = support_y-stepper_center[1]
sg_radius = sg_teeth*mod/2
lg_radius = (math.sqrt(lg_x**2 + lg_y**2)-sg_radius)
def findRodInter(n_x, n_y):
p = Point(center_x, center_y)
@ -113,6 +122,36 @@ def createOutline(ex_amount):
base = base.edges('|Z').edges('<<Y[-2]').fillet(5)
return base
# Based on https://github.com/gumyr/cq_warehouse/issues/42 from jdegs
def boreHole(caph_diam, caph_dep, step_dep, thd_diam, thd_dep):
s_p0 = ( #cap head circle
cq.Sketch()
.circle(caph_diam/2)
)
s_p1 = ( #rect slot with circular cut-ends
cq.Sketch()
.circle(caph_diam/2)
.rect(caph_diam,thd_diam,mode='i')
)
s_p2 = ( #thread circle
cq.Sketch()
.circle(thd_diam/2)
)
f_fancyh = ( #assemble components
cq.Workplane()
.placeSketch(s_p0)
.extrude(caph_dep).faces(">Z").workplane()
.placeSketch(s_p1)
.extrude(step_dep).faces(">Z").workplane()
.placeSketch(s_p2)
.extrude(thd_dep)
)
return f_fancyh.rotate((1,0,0),(0,0,0),180)
lid = createOutline(-lid_thicknesss).translate((0,0,part_thinkness))
base = createOutline(part_thinkness)
@ -137,7 +176,7 @@ base = base.faces('<<Z[0]').workplane().vLine(offset+loop_width, forConstruction
.close().cutBlind(-lid_thicknesss)
base = base.faces('>>Z[0]').workplane().center(stepper_center[0], -stepper_center[1])\
.circle(22.5/2)\
.circle(stepper_mount_dia/2)\
.pushPoints([(stepper_hole_radius*math.cos(math.radians(45+slant_degree)),\
stepper_hole_radius*math.sin(math.radians(45+slant_degree))),\
(stepper_hole_radius*math.cos(math.radians(135+slant_degree)),\
@ -152,17 +191,18 @@ lid = lid.cut(base)
copy = lid.faces('>>Z[0]').workplane().vLine(-offset-wall_width, forConstruction=True).polarLine(stepper_motor_size*2, slant_degree)\
.polarLine(-2*stepper_motor_size, 90+slant_degree)\
.hLine(-3*stepper_motor_size).close().cutThruAll()
lid = lid.faces('>Z[0]').shell(.000001-wall_width)
lid = lid.faces('>Z[0]').shell(-wall_width+hack_num, kind='arc')
lid = lid.add(copy)
lid = lid.faces('>Z[1]').workplane().center(stepper_center[0], -stepper_center[1])\
.circle(5).extrude(lid_thicknesss-wall_width)
lid = lid.faces('>Z[0]').workplane().circle(5/2).cutThruAll()
.circle(sg_radius+mod).extrude(lid_thicknesss-wall_width)
lid = lid.faces('>Z[0]').workplane().circle(lid_stepper_hole/2).cutThruAll()
base = base.faces('<Z[1]').workplane().center(lg_x, lg_y).circle(lg_radius+2*mod).cutBlind(-gear_thinkness-gear_gap)
base = base.faces('<Z[2]').workplane().hLine(support_radius, forConstruction=True)\
.threePointArc((-support_radius,-support_radius/2),(0,support_radius))\
.polarLine(support_radius, -slant_degree)\
base = base.faces('<Z[2]').workplane().circle(support_radius).extrude(-lid_thicknesss+wall_width)
base = base.faces('<Z[2]').workplane().vLine(support_radius-wall_width/2)\
.hLine(support_radius)\
.polarLine(support_radius, 270-slant_degree)\
.close().extrude(-lid_thicknesss+wall_width)
base = base.faces('<Z[2]').workplane().circle(large_gear_diameter/2-gear_offset).extrude(gear_thinkness/2)
base = base.faces('<Z[2]').workplane().circle(m3_tap/2).cutBlind(-part_thinkness/2+wall_width)
@ -172,35 +212,42 @@ base = base.faces('<<Y[-1]').workplane().center(-5,0).circle(6.5/2).cutBlind(-su
base = base.faces('<<Y[-1]').workplane().circle(8.5/2).cutBlind(-support_radius-mount_gap)
# Fastener
base = base.faces('<<Y[-1]').workplane().circle((fastener_width+1)/2).cutBlind(-fastener_hole_depth)
fastener = base.faces('<<Y[-4]').workplane().circle(fastener_width/2).extrude(fastener_hole_depth+fastener_h_spacing+fastener_height, combine=False)
base = base.faces('<<Y[-1]').workplane().circle(fastener_width/2+fastener_gap).cutBlind(-fastener_hole_depth)
fastener = base.faces('<<Y[-4]').workplane().circle(fastener_width/2)\
.extrude(fastener_hole_depth+fastener_h_spacing+fastener_height, combine=False)
fastener = fastener.faces('<<Y[-1]').workplane().center(-fastener_length,0)\
.line(20,-fastener_width/2)\
.vLine(-fastener_width/18)\
.lineTo(fastener_length,-fastener_width/2)\
.vLine(fastener_width)\
.lineTo(0,fastener_width/18)\
.close().extrude(-fastener_height)
fastener = fastener.faces('<<Y[-1]').workplane().circle(fastener_width/6).extrude(-fastener_height)
fastener = fastener.faces('<<Y[-1]').center(fastener_length,0)\
.sketch().regularPolygon(8.5/2,6,tag='outer')\
.finalize().cutBlind(-4)
fastener = fastener.faces('<<Y[-6]').workplane().circle(5/2).cutThruAll()
.sketch().regularPolygon(hex_diameter/2,6)\
.finalize().cutBlind(-hex_depth)
fastener = fastener.faces('<<Y[-6]').workplane().circle(m5_passthrough/2).cutThruAll()
fastener = fastener.faces('<<Y[-6]').workplane().rect(hex_diameter,hex_diameter/2).cutBlind(-step_dep)
# Lid large gear mount point
lid = lid.faces('>Z[0]').workplane().center(lg_x,-lg_y)\
.hLine(support_radius, forConstruction=True)\
.threePointArc((-support_radius, support_radius/2),(0,-support_radius))\
.polarLine(support_radius, slant_degree)\
.close().extrude(-lid_thicknesss+wall_width)
lid = lid.faces('>Z[0]').workplane().circle(large_gear_diameter/2-gear_offset).extrude(gear_thinkness/2)
lid = lid.faces('>Z[0]').workplane().circle(2).cutThruAll()
lid = lid.faces('<Z[0]').workplane().circle(m3_head_diameter/2).cutBlind(-m3_head_depth)
lid = lid.faces('>Z[0]').workplane().center(lg_x+hack_num,-lg_y)\
.circle(support_radius).extrude(-lid_thicknesss+wall_width)
lid = lid.faces('>Z[0]').workplane().center(-hack_num, 0).vLine(-support_radius+wall_width/2)\
.hLine(support_radius)\
.polarLine(-support_radius, 270+slant_degree)\
.close().extrude(-lid_thicknesss+wall_width)
# Lid Holes
lid = lid.faces('<Z[0]').workplane().center(-stepper_motor_size+wall_width,-stepper_motor_size+offset/2-loop_width)\
.circle(m3_passthrough/2).cutThruAll()
drill = lid.faces('<Z[0]').workplane().circle(m3_tap/2)\
lid = lid.faces('>Z[0]').workplane().circle(large_gear_diameter/2-gear_offset).extrude(gear_thinkness/2)
cut = boreHole(m3_head_diameter, m3_head_depth, step_dep, m3_passthrough, m3_passthrough*2).translate(lid.faces('<Z[0]').workplane().val())
lid = lid.cut(cut)
c = lid.faces('<Z[0]').workplane().center(-stepper_motor_size+wall_width,-stepper_motor_size+offset/2-loop_width).val()
drill = lid.faces('<Z[0]').workplane().center(-stepper_motor_size+wall_width,-stepper_motor_size+offset/2-loop_width).circle(m3_tap/2)\
.extrude(-part_thinkness+wall_width, combine=False)
cut = boreHole(m3_head_diameter, m3_head_depth, step_dep, m3_passthrough, m3_passthrough).translate(c)
base = base.cut(drill)
lid = lid.faces('<Z[0]').workplane().circle(m3_head_diameter/2).cutBlind(-m3_head_depth)
lid = lid.cut(cut)
# Gears
l_gear = cq.Workplane('XY').gear(SpurGear(module=mod,
@ -214,19 +261,26 @@ s_gear = cq.Workplane('XY').gear(SpurGear(module=mod,
# Stepper motor mount point
tab_distance = 2
tab_distance = 4
shaft_diameter = 5
copy = s_gear.faces('<Z[0]').workplane().vLine(tab_distance, forConstruction=True)\
.hLine(10).vLine(-10).hLine(-20).vLine(10)\
.close().cutThruAll()
s_gear = s_gear.faces('<Z[0]').sketch().circle(shaft_diameter/2).finalize().cutThruAll()
s_gear = s_gear.add(copy)
cut = cq.Workplane('XY').circle(shaft_diameter/2).extrude(gear_thinkness)
cut = cut.workplane().vLine(2*tab_distance, forConstruction=True).rect(shaft_diameter,tab_distance).cutThruAll()
s_gear = s_gear.cut(cut)
s_gear = s_gear.translate((stepper_center[0],stepper_center[1],(gear_thinkness-gear_offset)/2))
# Render
show_object(base, name='Follow Focus Base')
show_object(lid, name='Follow Focus Lid')
show_object(fastener, name='Follow Focus Fastener')
show_object(l_gear, name='Follow Focus Large Gear')
show_object(s_gear, name='Follow Focus Small Gear')
show_object(base, name='Follow Focus Base', options={"color": (10, 10, 10)})
show_object(lid, name='Follow Focus Lid', options={"color": (10, 10, 10)})
show_object(fastener, name='Follow Focus Fastener', options={"color": (10, 10, 10)})
show_object(l_gear, name='Follow Focus Large Gear', options={"color": (10, 10, 10)})
show_object(s_gear, name='Follow Focus Small Gear', options={"color": (10, 10, 10)})
# Export STL
fastener = fastener.rotateAboutCenter((1,0,0), 90).rotateAboutCenter((0,1,0), -slant_degree)
lid = lid.rotateAboutCenter((1,0,0), 180).rotateAboutCenter((0,0,1), -slant_degree)
base = base.rotateAboutCenter((0,0,1), slant_degree)
cq.exporters.export(base, 'follow-focus-base.stl')
cq.exporters.export(lid, 'follow-focus-lid.stl')
cq.exporters.export(fastener, 'follow-focus-fastener.stl')
cq.exporters.export(l_gear, 'follow-focus-large_gear.stl')
cq.exporters.export(s_gear, 'follow-focus-small_gear.stl')

25
slider.py Normal file
View File

@ -0,0 +1,25 @@
import cadquery as cq
from cadquery import exporters
slider_length=700
slider_width=50
path='20-2040.dxf'
bar_l = (
cq.importers.importDXF(path)
.wires().toPending()
.extrude(slider_length)
.translate((0, -slider_width/2, 0))
)
bar_r = (
cq.importers.importDXF(path)
.wires().toPending()
.extrude(slider_length)
.translate((0, slider_width/2, 0))
)
# Render
show_object(bar_l, name='Left Bar', options={"color": (20, 20, 20)})
show_object(bar_r, name='Right Bar', options={"color": (20, 20, 20)})