codeCAD/SyncGrips.py
2026-03-13 18:06:39 +01:00

89 lines
2.7 KiB
Python

#%%
from build123d import *
from ocp_vscode import *
import copy
set_defaults(reset_camera=Camera.KEEP, render_joints=True, helper_scale=8)
#%%
sensor_width = 35
r_sens = 6
wall_thickness = 3
t = 2.5 # sheet thickness
w1 = sensor_width + 2* wall_thickness #sensor casing
w2 = 150 #sensors center placed at corners of w2*w2 square
h = 85 # total height
h1 = 20 # sensor casing height
h2 = 12
h3 = 35# sensor casing + mpu height
r = 25 # grip radius
w3 = 20 # upper mount dx
r1 = 8 # bending radius
locs = ((0,h+10), (-10,h-10),(10,h-10)) #locations of screws
handle_len = w2+w1
l = w2/2+sensor_width+r1+5 # half of the length
#%%
with BuildPart() as part_builder:
with BuildSketch() as profile_sketch:
with BuildLine() as line_builder:
line = Polyline((-w3, h+r/2),(-w3, h-r),(-l, 0),\
(l,0),(w3,h-r), (w3,h+r/2), close=False)
line1 = fillet(radius=r1,objects=line.vertices())
w = offset(amount=t)
make_face()
extrude(amount=w1)
with BuildPart() as holes:
with BuildSketch(part_builder.faces().filter_by(Plane.YZ)[0]) as hole_sk:
dh = 10
dl = 5
with Locations((-dl,-dh),(dl,dh),(-dl,dh),(dl,-dh)):
Circle(2.05)
#SlotCenterToCenter(4,4, rotation=90)
extrude(amount=-50, both=True)
with BuildPart() as handle:
with BuildSketch(Plane.XY) as profile_sk:
with Locations((0,h)):
Circle(r)
extrude(amount=handle_len)
ch = r-w3+4
with Locations((w3+ch/2-t,h,w1/2), (-w3-ch/2+t,h,w1/2), (w3+ch/2-t,h,w2+w1/2), (-w3-ch/2+t,h,w2+w1/2)):
Box(ch, r*2, w1, mode=Mode.SUBTRACT)
add(holes, mode=Mode.SUBTRACT)
with BuildPart() as sensor_cutout:
with BuildSketch(Plane.XZ) as sensor_sk1:
d = 0
Rectangle(22,26)
sensor_space = extrude(amount=-14)
faces = (sensor_space.edges().group_by(Axis.Y)[-1] | Axis.Z)
#chamfer(objects=faces, length=6)
with BuildPart() as sensorhole:
with BuildSketch(Plane.XZ) as sensorhole_sk:
with Locations((-sensor_width/2,0)):
Circle(1.55)
extrude(amount=-14)
with BuildPart() as sensors:
dz = -5
ds = 4
with Locations((w2/2+ds,dz,w1/2), (w2/2+ds,dz,w2+w1/2)):
#Box(w1, 5, w1, mode=Mode.ADD)
add(sensor_cutout)
with Locations(((-w2/2-ds,dz,w1/2),(-w2/2-ds,dz,w2+w1/2))):
add(sensor_cutout.part.mirror(Plane.YZ))
upper_sheet = part_builder.part - holes.part - sensors.part
lower_sheet = Location((0,0,handle_len-w1))*upper_sheet
show(upper_sheet, lower_sheet,handle.part,reset_camera=False)
#%%
#%%
syncgrips = Compound(children=[sensor_cutout.part, sensor_cutout.part.mirror(Plane.YZ)])