1 changed files with 286 additions and 0 deletions
@ -0,0 +1,286 @@ |
|||||||
|
{ |
||||||
|
"cells": [ |
||||||
|
{ |
||||||
|
"cell_type": "code", |
||||||
|
"id": "initial_id", |
||||||
|
"metadata": { |
||||||
|
"collapsed": true, |
||||||
|
"ExecuteTime": { |
||||||
|
"end_time": "2026-05-22T01:25:54.666792544Z", |
||||||
|
"start_time": "2026-05-22T01:25:54.440667158Z" |
||||||
|
} |
||||||
|
}, |
||||||
|
"source": [ |
||||||
|
"from build123d import *\n", |
||||||
|
"from ocp_vscode import show, set_port\n", |
||||||
|
"\n", |
||||||
|
"A3_largueur = 105\n", |
||||||
|
"A3_hauteur = 148\n", |
||||||
|
"\n", |
||||||
|
"stand_bordure = 5 # de chaque coté\n", |
||||||
|
"stand_epaisseur = 5\n", |
||||||
|
"stand_angle_pied = 80 # deg\n", |
||||||
|
"\n", |
||||||
|
"pied_longueur = 100 # 5mm pour le bend\n", |
||||||
|
"pied_epaisseur = 100 # 5mm pour le bend\n", |
||||||
|
"\n", |
||||||
|
"rail_pignon_hauteur = 10\n", |
||||||
|
"pignons_diam = 10\n", |
||||||
|
"pignons_profondeur = 10\n", |
||||||
|
"\n", |
||||||
|
"stand_largueur = stand_bordure * 2 + A3_largueur\n", |
||||||
|
"\n", |
||||||
|
"with BuildPart() as bp:\n", |
||||||
|
" Box(pied_longueur, stand_largueur, stand_epaisseur)\n", |
||||||
|
"\n", |
||||||
|
" foot_face = faces().filter_by(Plane.YZ).sort_by(Axis.X)[0]\n", |
||||||
|
" print(Plane(foot_face))\n", |
||||||
|
" with BuildSketch(foot_face):\n", |
||||||
|
" Rectangle(stand_epaisseur, stand_largueur * (2 / 3))\n", |
||||||
|
" extrude(amount=-0.8 * stand_pied, mode=Mode.SUBTRACT)\n", |
||||||
|
"\n", |
||||||
|
"stand = bp.part\n", |
||||||
|
"\n", |
||||||
|
"set_port(3939)\n", |
||||||
|
"show(stand)" |
||||||
|
], |
||||||
|
"outputs": [ |
||||||
|
{ |
||||||
|
"name": "stdout", |
||||||
|
"output_type": "stream", |
||||||
|
"text": [ |
||||||
|
"Plane(o=(-101.50, 0.00, 0.00), x=(0.00, 0.00, 1.00), z=(-1.00, -0.00, 0.00))\n", |
||||||
|
"c\n" |
||||||
|
] |
||||||
|
} |
||||||
|
], |
||||||
|
"execution_count": 15 |
||||||
|
}, |
||||||
|
{ |
||||||
|
"metadata": { |
||||||
|
"ExecuteTime": { |
||||||
|
"end_time": "2026-05-22T17:29:08.227823509Z", |
||||||
|
"start_time": "2026-05-22T17:29:07.494508009Z" |
||||||
|
} |
||||||
|
}, |
||||||
|
"cell_type": "code", |
||||||
|
"source": [ |
||||||
|
"A3_largueur = 105\n", |
||||||
|
"A3_hauteur = 148\n", |
||||||
|
"\n", |
||||||
|
"stand_bordure = 5 # de chaque coté\n", |
||||||
|
"stand_epaisseur = 5\n", |
||||||
|
"stand_angle_pied = 75 # deg\n", |
||||||
|
"\n", |
||||||
|
"pied_longueur = 50 # 5mm pour le bend\n", |
||||||
|
"\n", |
||||||
|
"rail_pignon_hauteur = 10\n", |
||||||
|
"pignons_diam = 10\n", |
||||||
|
"pignons_profondeur = 10\n", |
||||||
|
"\n", |
||||||
|
"stand_largueur = stand_bordure * 2 + A3_largueur\n", |
||||||
|
"stand_hauteur = A3_hauteur + stand_bordure\n", |
||||||
|
"\n", |
||||||
|
"with BuildPart() as cadre:\n", |
||||||
|
" d = Vector(1, 0, 0).rotate(Axis.Y, -stand_angle_pied)\n", |
||||||
|
" with BuildLine(Plane.XZ) as side_line:\n", |
||||||
|
" l1 = Line((stand_hauteur + stand_bordure, 0), (0, 0))\n", |
||||||
|
" l2 = PolarLine(l1 @ 1, length=pied_longueur, direction=d, length_mode=LengthMode.VERTICAL)\n", |
||||||
|
" fillet(side_line.vertices(), 3)\n", |
||||||
|
" make_brake_formed(\n", |
||||||
|
" thickness=stand_epaisseur,\n", |
||||||
|
" station_widths=stand_largueur,\n", |
||||||
|
" #side=Side.BOTH,\n", |
||||||
|
" )\n", |
||||||
|
"\n", |
||||||
|
" bottom_face = faces().filter_by(Plane.XY).sort_by(Axis.Z)[0]\n", |
||||||
|
" with BuildSketch(bottom_face):\n", |
||||||
|
" Rectangle(A3_largueur - 10, A3_hauteur - 10)\n", |
||||||
|
" extrude(amount=-1.8, mode=Mode.SUBTRACT)\n", |
||||||
|
"\n", |
||||||
|
" stand_backface = faces().filter_by(Plane.XY).sort_by(Axis.Z)[-1]\n", |
||||||
|
" with BuildSketch(stand_backface):\n", |
||||||
|
" with Locations((0, stand_backface.width / 2)):\n", |
||||||
|
" Rectangle(A3_largueur - 3.2,\n", |
||||||
|
" A3_hauteur + stand_bordure,\n", |
||||||
|
" align=(Align.CENTER, Align.MAX))\n", |
||||||
|
" with BuildSketch(stand_backface.offset(-3.2)):\n", |
||||||
|
" with Locations((0, stand_backface.width / 2)):\n", |
||||||
|
" Rectangle(A3_largueur,\n", |
||||||
|
" A3_hauteur + stand_bordure,\n", |
||||||
|
" align=(Align.CENTER, Align.MAX))\n", |
||||||
|
" loft(mode=Mode.SUBTRACT)\n", |
||||||
|
"\n", |
||||||
|
"cadre = cadre.part\n", |
||||||
|
"\n", |
||||||
|
"clearance = 0.2\n", |
||||||
|
"\n", |
||||||
|
"with BuildPart() as rail:\n", |
||||||
|
" with BuildSketch(Plane.XY) as sk1:\n", |
||||||
|
" Rectangle(\n", |
||||||
|
" A3_hauteur + stand_bordure - clearance,\n", |
||||||
|
" A3_largueur - 3.2 - clearance * 2,\n", |
||||||
|
" )\n", |
||||||
|
" with BuildSketch(Plane.XY.offset(-3.2)) as sk2:\n", |
||||||
|
" Rectangle(\n", |
||||||
|
" A3_hauteur + stand_bordure - clearance,\n", |
||||||
|
" A3_largueur - clearance * 2,\n", |
||||||
|
" )\n", |
||||||
|
" loft()\n", |
||||||
|
" # Optional: add a small fillet to help insertion\n", |
||||||
|
" # fillet(rail.edges().filter_by(Axis.Z), 0.3)\n", |
||||||
|
"\n", |
||||||
|
"rail = rail.part\n", |
||||||
|
"\n", |
||||||
|
"# Fixed part (cadre) gets a RigidJoint — the anchor point of the slot\n", |
||||||
|
"cadre_joint = RigidJoint(\n", |
||||||
|
" label=\"slot\",\n", |
||||||
|
" to_part=cadre,\n", |
||||||
|
" joint_location=Location(stand_backface.center()),\n", |
||||||
|
")\n", |
||||||
|
"\n", |
||||||
|
"# Moving part (rail) gets the LinearJoint — defines the slide axis\n", |
||||||
|
"rail_joint = LinearJoint(\n", |
||||||
|
" label=\"insert\",\n", |
||||||
|
" to_part=rail,\n", |
||||||
|
" axis=Axis((rail.faces()\n", |
||||||
|
" .filter_by(Plane.YZ)\n", |
||||||
|
" .sort_by(Axis.X)[-1]\n", |
||||||
|
" .offset(-(A3_hauteur + stand_bordure)/2))\n", |
||||||
|
" .center()\n", |
||||||
|
" + (0, 0, 3.2 / 2), (1, 0, 0)),\n", |
||||||
|
" linear_range=(0, A3_hauteur + stand_bordure)\n", |
||||||
|
")\n", |
||||||
|
"\n", |
||||||
|
"# Connect and set position\n", |
||||||
|
"cadre_joint.connect_to(rail_joint, position=0)\n", |
||||||
|
"\n", |
||||||
|
"# Or move to a specific position\n", |
||||||
|
"cadre_joint.connect_to(rail_joint, position=0)\n", |
||||||
|
"assembly = Compound(children=[cadre, rail])\n", |
||||||
|
"cog = assembly.center(CenterOf.MASS)\n", |
||||||
|
"cog_marker = Sphere(2).locate(Location(cog))\n", |
||||||
|
"show(Compound(children=[cadre, rail]), cog_marker)" |
||||||
|
], |
||||||
|
"id": "a32cfe0f76b167e", |
||||||
|
"outputs": [ |
||||||
|
{ |
||||||
|
"name": "stdout", |
||||||
|
"output_type": "stream", |
||||||
|
"text": [ |
||||||
|
"cc+\n" |
||||||
|
] |
||||||
|
} |
||||||
|
], |
||||||
|
"execution_count": 92 |
||||||
|
}, |
||||||
|
{ |
||||||
|
"metadata": { |
||||||
|
"ExecuteTime": { |
||||||
|
"end_time": "2026-05-22T17:26:35.126466252Z", |
||||||
|
"start_time": "2026-05-22T17:26:35.071890866Z" |
||||||
|
} |
||||||
|
}, |
||||||
|
"cell_type": "code", |
||||||
|
"source": "Compound(children=[cadre, rail]).center(CenterOf.MASS)", |
||||||
|
"id": "9c05871fcb7d0f44", |
||||||
|
"outputs": [ |
||||||
|
{ |
||||||
|
"data": { |
||||||
|
"text/plain": [ |
||||||
|
"Vector(54.041693811711, -57.5, 6.2695039269171)" |
||||||
|
] |
||||||
|
}, |
||||||
|
"execution_count": 89, |
||||||
|
"metadata": {}, |
||||||
|
"output_type": "execute_result" |
||||||
|
} |
||||||
|
], |
||||||
|
"execution_count": 89 |
||||||
|
}, |
||||||
|
{ |
||||||
|
"metadata": { |
||||||
|
"ExecuteTime": { |
||||||
|
"end_time": "2026-05-22T17:26:45.250648084Z", |
||||||
|
"start_time": "2026-05-22T17:26:44.934770412Z" |
||||||
|
} |
||||||
|
}, |
||||||
|
"cell_type": "code", |
||||||
|
"source": [ |
||||||
|
"cog = Compound(children=[cadre, rail]).center(CenterOf.MASS)\n", |
||||||
|
"cog_marker = Sphere(2).locate(Location(cog))\n", |
||||||
|
"show(cadre, rail, cog_marker)" |
||||||
|
], |
||||||
|
"id": "1d894551360c62d4", |
||||||
|
"outputs": [ |
||||||
|
{ |
||||||
|
"name": "stdout", |
||||||
|
"output_type": "stream", |
||||||
|
"text": [ |
||||||
|
"c++\n" |
||||||
|
] |
||||||
|
} |
||||||
|
], |
||||||
|
"execution_count": 90 |
||||||
|
}, |
||||||
|
{ |
||||||
|
"metadata": { |
||||||
|
"ExecuteTime": { |
||||||
|
"end_time": "2026-05-22T12:19:32.560992117Z", |
||||||
|
"start_time": "2026-05-22T12:19:32.115315967Z" |
||||||
|
} |
||||||
|
}, |
||||||
|
"cell_type": "code", |
||||||
|
"source": [ |
||||||
|
"sheet_thickness = 4 * MM\n", |
||||||
|
"\n", |
||||||
|
"# Create the main body from a side profile\n", |
||||||
|
"with BuildPart() as side:\n", |
||||||
|
" d = Vector(1, 0, 0).rotate(Axis.Y, 60)\n", |
||||||
|
" with BuildLine(Plane.XZ) as side_line:\n", |
||||||
|
" l1 = Line((0, 65), (170 / 2, 65))\n", |
||||||
|
" l2 = PolarLine(l1 @ 1, length=65, direction=d, length_mode=LengthMode.VERTICAL)\n", |
||||||
|
" l3 = Line(l2 @ 1, (170 / 2, 0))\n", |
||||||
|
" fillet(side_line.vertices(), 7)\n", |
||||||
|
" make_brake_formed(\n", |
||||||
|
" thickness=sheet_thickness,\n", |
||||||
|
" station_widths=[40, 40, 40, 112.52 / 2, 112.52 / 2, 112.52 / 2],\n", |
||||||
|
" side=Side.RIGHT,\n", |
||||||
|
" )\n", |
||||||
|
"show(side.part)" |
||||||
|
], |
||||||
|
"id": "11df73221c8aad94", |
||||||
|
"outputs": [ |
||||||
|
{ |
||||||
|
"name": "stdout", |
||||||
|
"output_type": "stream", |
||||||
|
"text": [ |
||||||
|
"+\n" |
||||||
|
] |
||||||
|
} |
||||||
|
], |
||||||
|
"execution_count": 18 |
||||||
|
} |
||||||
|
], |
||||||
|
"metadata": { |
||||||
|
"kernelspec": { |
||||||
|
"display_name": "Python 3", |
||||||
|
"language": "python", |
||||||
|
"name": "python3" |
||||||
|
}, |
||||||
|
"language_info": { |
||||||
|
"codemirror_mode": { |
||||||
|
"name": "ipython", |
||||||
|
"version": 2 |
||||||
|
}, |
||||||
|
"file_extension": ".py", |
||||||
|
"mimetype": "text/x-python", |
||||||
|
"name": "python", |
||||||
|
"nbconvert_exporter": "python", |
||||||
|
"pygments_lexer": "ipython2", |
||||||
|
"version": "2.7.6" |
||||||
|
} |
||||||
|
}, |
||||||
|
"nbformat": 4, |
||||||
|
"nbformat_minor": 5 |
||||||
|
} |
||||||
Loading…
Reference in new issue