codeCAD/v2_SyncGrips.ipynb
2026-02-27 02:05:50 +01:00

221 lines
6.4 KiB
Plaintext

{
"cells": [
{
"cell_type": "markdown",
"id": "667ffcc6-563f-442b-9726-e15a2a45c01f",
"metadata": {},
"source": [
"# SyncGrips v2"
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "c8a0e581-2963-424c-a258-f1de92180674",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Overwriting auto display for cadquery Workplane and Shape\n"
]
}
],
"source": [
"import timeit\n",
"tic = timeit.default_timer()\n",
"\n",
"import cadquery as cq\n",
"from build123d import *\n",
"\n",
"from jupyter_cadquery import (\n",
" versions,\n",
" show, PartGroup, Part, \n",
" get_viewer, close_viewer, get_viewers, close_viewers, open_viewer, set_defaults, get_defaults, open_viewer,\n",
" get_pick,\n",
")\n",
"from jupyter_cadquery.ocp_utils import webcol_to_cq\n",
"\n",
"from jupyter_cadquery.replay import replay, enable_replay, disable_replay\n",
"close_viewers()\n",
"set_defaults(\n",
" cad_width=640, \n",
" height=480, \n",
" viewer=\"syncgrips_v2\"\n",
")\n",
"cv = open_viewer(\"syncgrips_v2\",\n",
" anchor=\"right\", \n",
" glass=True, \n",
" theme=\"dark\",\n",
" tools=True) # sets default viewer\n"
]
},
{
"cell_type": "code",
"execution_count": 89,
"id": "e694a533-04eb-4783-84ca-faf15d983361",
"metadata": {},
"outputs": [],
"source": [
"sensor_width = 35\n",
"r_sens = 6\n",
"wall_thickness = 3\n",
"t = 2.5 # sheet thickness\n",
"w1 = sensor_width + 2* wall_thickness #sensor casing\n",
"w2 = 150 #sensors center placed at corners of w2*w2 square\n",
"h = 85 # total height\n",
"h1 = 20 # sensor casing height\n",
"h2 = 12\n",
"h3 = 35# sensor casing + mpu height\n",
"r = 25 # grip radius\n",
"w3 = 20 # upper mount dx \n",
"r1 = 8 # bending radius\n",
"locs = ((0,h+10), (-10,h-10),(10,h-10)) #locations of screws\n",
"handle_len = w2+w1\n",
"l = w2/2+sensor_width+r1+5 # half of the length"
]
},
{
"cell_type": "code",
"execution_count": 108,
"id": "2461ad9b-3cf5-4517-9b66-cee2e0bc5b5b",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"100% ⋮————————————————————————————————————————————————————————————⋮ (3/3) 0.23s\n"
]
},
{
"data": {
"text/plain": [
"<cad_viewer_widget.widget.CadViewer at 0x7b1cff93a5c0>"
]
},
"execution_count": 108,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"with BuildPart() as part_builder:\n",
" with BuildSketch() as profile_sketch:\n",
" with BuildLine() as line_builder:\n",
" line = Polyline((-w3, h+r/2),(-w3, h-r),(-l, 0),\\\n",
" (l,0),(w3,h-r), (w3,h+r/2), close=False)\n",
" line1 = fillet(radius=r1,objects=line.vertices())\n",
" w = offset(amount=t) \n",
" make_face()\n",
" extrude(amount=w1)\n",
" \n",
"with BuildPart() as holes:\n",
" with BuildSketch(part_builder.faces().filter_by(Plane.YZ)[0]) as hole_sk:\n",
" dh = 10\n",
" dl = 5\n",
" with Locations((-dl,-dh),(dl,dh),(-dl,dh),(dl,-dh)):\n",
" Circle(2.05)\n",
" #SlotCenterToCenter(4,4, rotation=90)\n",
" extrude(amount=-50, both=True)\n",
" \n",
"with BuildPart() as handle:\n",
" with BuildSketch(Plane.XY) as profile_sk:\n",
" with Locations((0,h)):\n",
" Circle(r)\n",
" extrude(amount=handle_len)\n",
" ch = r-w3+4\n",
" 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)):\n",
" Box(ch, r*2, w1, mode=Mode.SUBTRACT)\n",
" add(holes, mode=Mode.SUBTRACT)\n",
" \n",
"with BuildPart() as sensors:\n",
" dz = -5\n",
" ds = 4\n",
" with Locations((w2/2+ds,dz,w1/2), (w2/2+ds,dz,w2+w1/2)):\n",
" #Box(w1, 5, w1, mode=Mode.ADD)\n",
" add(sensor_cutout)\n",
" with Locations(((-w2/2-ds,dz,w1/2),(-w2/2-ds,dz,w2+w1/2))):\n",
" add(sensor_cutout.part.mirror(Plane.YZ))\n",
" \n",
"upper_sheet = part_builder.part - holes.part - sensors.part\n",
"lower_sheet = Location((0,0,handle_len-w1))*upper_sheet\n",
"show(upper_sheet, lower_sheet,handle.part,reset_camera=False)"
]
},
{
"cell_type": "code",
"execution_count": 28,
"id": "74b1b118-4c15-4e03-a029-670d8198db72",
"metadata": {},
"outputs": [],
"source": [
"part_builder.faces().filter_by(Plane.YZ)[0]"
]
},
{
"cell_type": "code",
"execution_count": 111,
"id": "6fe18aef-3215-43e4-8d00-1ffd45a44f1d",
"metadata": {},
"outputs": [],
"source": [
"with BuildPart() as sensor_cutout:\n",
" with BuildSketch(Plane.XZ) as sensor_sk1:\n",
" d = 0\n",
" #Rectangle(22,26)\n",
" \n",
" sensor_space = extrude(amount=-14)\n",
" faces = (sensor_space.edges().group_by(Axis.Y)[-1] | Axis.Z)\n",
" #chamfer(objects=faces, length=6)\n",
" \n",
"with BuildPart() as sensorhole:\n",
" with BuildSketch(Plane.XZ) as sensorhole_sk: \n",
" with Locations((-sensor_width/2,0)):\n",
" Circle(1.55)\n",
" extrude(amount=-14)"
]
},
{
"cell_type": "code",
"execution_count": 113,
"id": "ffef54a9-57a6-4477-9836-2c770b451182",
"metadata": {},
"outputs": [],
"source": [
"sensor_cutout.part + sensor_cutout.part.mirror(Plane.YZ)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "80097045-32aa-4744-a56a-9892e60d361a",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.8"
}
},
"nbformat": 4,
"nbformat_minor": 5
}