2 changed files with 383 additions and 0 deletions
@ -0,0 +1,66 @@ |
|||||||
|
{ |
||||||
|
"cells": [ |
||||||
|
{ |
||||||
|
"cell_type": "code", |
||||||
|
"id": "initial_id", |
||||||
|
"metadata": { |
||||||
|
"collapsed": true, |
||||||
|
"ExecuteTime": { |
||||||
|
"end_time": "2026-05-08T20:17:43.960196565Z", |
||||||
|
"start_time": "2026-05-08T20:17:41.069492709Z" |
||||||
|
} |
||||||
|
}, |
||||||
|
"source": [ |
||||||
|
"from build123d import *\n", |
||||||
|
"from ocp_vscode import show\n", |
||||||
|
"\n", |
||||||
|
"\n", |
||||||
|
"def make_test():\n", |
||||||
|
" with BuildPart() as p:\n", |
||||||
|
" Box(10,30,20)\n", |
||||||
|
" return p.part\n", |
||||||
|
"\n", |
||||||
|
"show(make_test())" |
||||||
|
], |
||||||
|
"outputs": [ |
||||||
|
{ |
||||||
|
"name": "stdout", |
||||||
|
"output_type": "stream", |
||||||
|
"text": [ |
||||||
|
"Using port 3939\n", |
||||||
|
"+\n" |
||||||
|
] |
||||||
|
}, |
||||||
|
{ |
||||||
|
"name": "stderr", |
||||||
|
"output_type": "stream", |
||||||
|
"text": [ |
||||||
|
"CameraKeepWarning: reset_camera is set to KEEP. If shown objects are not visible use the 'resize' and a 'view' button\n" |
||||||
|
] |
||||||
|
} |
||||||
|
], |
||||||
|
"execution_count": 1 |
||||||
|
} |
||||||
|
], |
||||||
|
"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 |
||||||
|
} |
||||||
@ -0,0 +1,317 @@ |
|||||||
|
{ |
||||||
|
"cells": [ |
||||||
|
{ |
||||||
|
"cell_type": "code", |
||||||
|
"id": "initial_id", |
||||||
|
"metadata": { |
||||||
|
"collapsed": true, |
||||||
|
"ExecuteTime": { |
||||||
|
"end_time": "2026-05-09T01:06:35.539444869Z", |
||||||
|
"start_time": "2026-05-09T01:06:34.603873035Z" |
||||||
|
} |
||||||
|
}, |
||||||
|
"source": [ |
||||||
|
"from ocp_vscode import show\n", |
||||||
|
"\n", |
||||||
|
"\"\"\"\n", |
||||||
|
"punch-guide — build123d\n", |
||||||
|
"4 pièces : superieure, inferieure, couvercle, (bac)\n", |
||||||
|
"Exporte chaque pièce en STEP et STL dans ./exports/\n", |
||||||
|
"\"\"\"\n", |
||||||
|
"\n", |
||||||
|
"from build123d import *\n", |
||||||
|
"\n", |
||||||
|
"# ─────────────────────────────────────────────────────────────────────────────\n", |
||||||
|
"# PARAMÈTRES — modifier ici uniquement\n", |
||||||
|
"# ─────────────────────────────────────────────────────────────────────────────\n", |
||||||
|
"\n", |
||||||
|
"# Fente (guide tract) — face droite, centrée en Y\n", |
||||||
|
"fente_largeur = 152.0 # mm — largeur de la fente -> Y\n", |
||||||
|
"fente_profondeur = 60.0 # mm — profondeur (longueur de la rainure) -> X\n", |
||||||
|
"fente_section = 2.0 # mm — hauteur de la section (épaisseur papier + jeu)\n", |
||||||
|
"\n", |
||||||
|
"# Zone à extruder du tract\n", |
||||||
|
"tract_extrusion_cote = 45 # mm\n", |
||||||
|
"tract_extrusion_x_offset = 10 # mm\n", |
||||||
|
"tract_extrusion_y_offset = 52 # mm\n", |
||||||
|
"tract_extrusion_center_x_offset = tract_extrusion_cote / 2 + tract_extrusion_x_offset\n", |
||||||
|
"tracte_extrusion_center_y_offset = tract_extrusion_cote / 2 + tract_extrusion_y_offset\n", |
||||||
|
"\n", |
||||||
|
"# extrudeuse\n", |
||||||
|
"hauteur_extrudeuse = 80 # mm\n", |
||||||
|
"longueur_extrudeuse = 205 # mm\n", |
||||||
|
"largueur_extrudeuse = 122.3 # mm\n", |
||||||
|
"# représente l'offsent du centre de la zone d'extrusion par rapport à l'avant de l'extreuse\n", |
||||||
|
"# TODO: a compéter\n", |
||||||
|
"# offset par rapport à l'avant de l'extrudeuse\n", |
||||||
|
"zone_extrusion_offset_avant = 40 # mm\n", |
||||||
|
"# offset par rapport au bas de l'extrudeuse\n", |
||||||
|
"zone_extrusion_offset_hauteur = 30 # mm\n", |
||||||
|
"\n", |
||||||
|
"# Cavité perforatrice\n", |
||||||
|
"jeu_cavite = 2 # mm\n", |
||||||
|
"cav_dim_x = longueur_extrudeuse + jeu_cavite\n", |
||||||
|
"cav_dim_y = largueur_extrudeuse + jeu_cavite\n", |
||||||
|
"cav_hauteur = hauteur_extrudeuse # mm — profondeur de creusement depuis le dessus\n", |
||||||
|
"\n", |
||||||
|
"# Trou d'évacuation (confettis)\n", |
||||||
|
"evac_taille = 48.0 # mm — côté du carré (45 + jeu)\n", |
||||||
|
"\n", |
||||||
|
"# Parois\n", |
||||||
|
"epaisseur_paroi_fond = 20 # mm\n", |
||||||
|
"epaisseur_paroi = 10 # mm\n", |
||||||
|
"epaisseur_fond = 10.0 # mm\n", |
||||||
|
"\n", |
||||||
|
"# Emboîtement\n", |
||||||
|
"emboitement_profondeur = 10.0 # mm\n", |
||||||
|
"emboitement_jeu = 0.3 # mm\n", |
||||||
|
"\n", |
||||||
|
"# Couvercle\n", |
||||||
|
"couvercle_epaisseur = 3.0 # mm\n", |
||||||
|
"couvercle_ouv_largeur = 150 # mm — ouverture X\n", |
||||||
|
"couvercle_ouv_profondeur = 60 # mm — ouverture Y\n", |
||||||
|
"\n", |
||||||
|
"# Bac\n", |
||||||
|
"bac_hauteur = 100.0 # mm\n", |
||||||
|
"\n", |
||||||
|
"# ─────────────────────────────────────────────────────────────────────────────\n", |
||||||
|
"# DIMENSIONS DÉRIVÉES\n", |
||||||
|
"# ─────────────────────────────────────────────────────────────────────────────\n", |
||||||
|
"\n", |
||||||
|
"# Fente\n", |
||||||
|
"# léger offset pour centrer la zone à extruder dans l'axe de l'extrudeuse\n", |
||||||
|
"fente_y = fente_largeur / 2 - tracte_extrusion_center_y_offset\n", |
||||||
|
"fente_z_abs = epaisseur_fond + zone_extrusion_offset_hauteur # hauteur absolue depuis le bas\n", |
||||||
|
"\n", |
||||||
|
"\n", |
||||||
|
"bloc_extrudeur_int_x = (fente_profondeur - tract_extrusion_center_x_offset\n", |
||||||
|
" + cav_dim_x - zone_extrusion_offset_avant)\n", |
||||||
|
"bloc_extrudeur_int_y = max(cav_dim_y, fente_largeur + fente_y)\n", |
||||||
|
"\n", |
||||||
|
"bloc_extrudeur_ext_x = bloc_extrudeur_int_x + 2 * epaisseur_paroi\n", |
||||||
|
"bloc_extrudeur_ext_y = bloc_extrudeur_int_y + 2 * epaisseur_paroi\n", |
||||||
|
"bloc_extrudeur_ext_z = epaisseur_fond + cav_hauteur\n", |
||||||
|
"\n", |
||||||
|
"# Position de la cavité dans le bloc extrudeur\n", |
||||||
|
"cav_x = (bloc_extrudeur_ext_x - cav_dim_x) / 2 # centrée en X\n", |
||||||
|
"cav_y = 0\n", |
||||||
|
"\n", |
||||||
|
"\n", |
||||||
|
"# Bac\n", |
||||||
|
"bac_ext_x = bloc_extrudeur_ext_x + 2 * (epaisseur_paroi + emboitement_jeu)\n", |
||||||
|
"bac_ext_y = bloc_extrudeur_ext_y + 2 * (epaisseur_paroi + emboitement_jeu)\n", |
||||||
|
"\n", |
||||||
|
"# Couvercle\n", |
||||||
|
"couv_ext_x = bloc_extrudeur_ext_x + 2 * (epaisseur_paroi + emboitement_jeu)\n", |
||||||
|
"couv_ext_y = bloc_extrudeur_ext_y + 2 * (epaisseur_paroi + emboitement_jeu)\n", |
||||||
|
"couv_ext_z = couvercle_epaisseur + emboitement_profondeur\n", |
||||||
|
"\n", |
||||||
|
"offset_couv = epaisseur_paroi + emboitement_jeu\n", |
||||||
|
"cav_centre_x = offset_couv + epaisseur_paroi + bloc_extrudeur_int_x / 2\n", |
||||||
|
"cav_centre_y = 0\n", |
||||||
|
"\n", |
||||||
|
"\n", |
||||||
|
"# ─────────────────────────────────────────────────────────────────────────────\n", |
||||||
|
"# PARTIE SUPÉRIEURE (chapeau)\n", |
||||||
|
"# ─────────────────────────────────────────────────────────────────────────────\n", |
||||||
|
"\n", |
||||||
|
"def make_bloc_extrudeur():\n", |
||||||
|
" with BuildPart() as p:\n", |
||||||
|
" # 1. Corps principal\n", |
||||||
|
" Box(bloc_extrudeur_ext_x, bloc_extrudeur_ext_y, bloc_extrudeur_ext_z)\n", |
||||||
|
" chamfer(edges().filter_by(Axis.Z), length=2)\n", |
||||||
|
"\n", |
||||||
|
" # 2. Cavité perforatrice (ouverte vers le haut)\n", |
||||||
|
" # On se met sur le haut du bloc, puis on extrude de la honteur\n", |
||||||
|
" top_face = faces().sort_by(Axis.Z)[-1]\n", |
||||||
|
" with BuildSketch(top_face) as sk:\n", |
||||||
|
" # Position relative au centre de la face (origine du sketch)\n", |
||||||
|
" with Locations(Location((cav_x + cav_dim_x / 2 - bloc_extrudeur_ext_x / 2, 0))):\n", |
||||||
|
" Rectangle(cav_dim_x, cav_dim_y)\n", |
||||||
|
"\n", |
||||||
|
" extrude(amount=-cav_hauteur, mode=Mode.SUBTRACT)\n", |
||||||
|
"\n", |
||||||
|
" # # 3. Fente latérale (débouche sur la face droite, X max)\n", |
||||||
|
" front_face = faces().sort_by(Axis.X)[-1]\n", |
||||||
|
" front_plane = Plane(\n", |
||||||
|
" origin=front_face.center(),\n", |
||||||
|
" x_dir=Vector(0, 1, 0), # direction X du sketch\n", |
||||||
|
" z_dir=Vector(1, 0, 0), # normale (vers l'extérieur)\n", |
||||||
|
" )\n", |
||||||
|
" with BuildSketch(front_plane) as sk:\n", |
||||||
|
" # Position relative au centre de la face (origine du sketch)\n", |
||||||
|
" # with Locations(Location((fente_y, fente_z_abs - bloc_extrudeur_ext_z))):\n", |
||||||
|
" with Locations(Location((fente_y, fente_z_abs - bloc_extrudeur_ext_z / 2))):\n", |
||||||
|
" Rectangle(fente_largeur, fente_section)\n", |
||||||
|
"\n", |
||||||
|
" extrude(amount=-fente_profondeur, mode=Mode.SUBTRACT)\n", |
||||||
|
" # ptit coup de chamfrein sur la fente\n", |
||||||
|
" chamfer(p.edges(Select.LAST), length=0.5)\n", |
||||||
|
"\n", |
||||||
|
" # # 4. Trou d'évacuation (perce le fond depuis en dessous)\n", |
||||||
|
" cav_floor = faces().filter_by(Axis.Z).sort_by(Axis.Z)[1]\n", |
||||||
|
" inner_fente_x = bloc_extrudeur_ext_x / 2 - fente_profondeur\n", |
||||||
|
" with BuildSketch(cav_floor) as sk:\n", |
||||||
|
" with Locations(Location((inner_fente_x\n", |
||||||
|
" + tract_extrusion_center_x_offset\n", |
||||||
|
" - 5, 0))):\n", |
||||||
|
" Rectangle(tract_extrusion_cote + 3, tract_extrusion_cote + 3)\n", |
||||||
|
" extrude(amount=-epaisseur_fond, mode=Mode.SUBTRACT)\n", |
||||||
|
" # ptit coup de chamfrein sur le trou\n", |
||||||
|
" chamfer(edges(Select.LAST), length=2)\n", |
||||||
|
"\n", |
||||||
|
" # # Trous de boulons pour fixer la trouyoteuse\n", |
||||||
|
" with Locations(cav_floor):\n", |
||||||
|
" with GridLocations(50, 60, 2, 2):\n", |
||||||
|
" Hole(radius=3)\n", |
||||||
|
"\n", |
||||||
|
" # Affichage du logo sur la face de la fente\n", |
||||||
|
" # centré, au dessus de la fente\n", |
||||||
|
" logo_shapes = import_svg(\"logo.svg\")\n", |
||||||
|
" min_x = min(s.bounding_box().min.X for s in logo_shapes)\n", |
||||||
|
" max_x = max(s.bounding_box().max.X for s in logo_shapes)\n", |
||||||
|
" cx = (min_x + max_x) / 2\n", |
||||||
|
"\n", |
||||||
|
" with BuildSketch(front_plane) as sk:\n", |
||||||
|
" add([s.translate((-cx, 5, 0)) for s in logo_shapes])\n", |
||||||
|
" scale(by=0.8)\n", |
||||||
|
"\n", |
||||||
|
" extrude(amount=-1.5, mode=Mode.SUBTRACT) # 1.5 mm de profondeur\n", |
||||||
|
"\n", |
||||||
|
" return p.part\n", |
||||||
|
"\n", |
||||||
|
"\n", |
||||||
|
"# ─────────────────────────────────────────────────────────────────────────────\n", |
||||||
|
"# PARTIE INFÉRIEURE (bac)\n", |
||||||
|
"# ─────────────────────────────────────────────────────────────────────────────\n", |
||||||
|
"\n", |
||||||
|
"def make_bac_recup():\n", |
||||||
|
" with BuildPart() as p:\n", |
||||||
|
" # Corps extérieur\n", |
||||||
|
" Box(bac_ext_x, bac_ext_y, bac_hauteur)\n", |
||||||
|
"\n", |
||||||
|
" top_edges = faces().sort_by(Axis.Z)[-1].edges()\n", |
||||||
|
" lateral_edges = edges().filter_by(Axis.Z)\n", |
||||||
|
" chamfer(top_edges + lateral_edges, length=2)\n", |
||||||
|
"\n", |
||||||
|
" top_face = faces().sort_by(Axis.Z)[-1]\n", |
||||||
|
"\n", |
||||||
|
" with BuildSketch(top_face) as sk:\n", |
||||||
|
" # Position relative au centre de la face (origine du sketch)\n", |
||||||
|
" with Locations(Location((0, 0))):\n", |
||||||
|
" Rectangle(bac_ext_x - 2 * epaisseur_paroi, bac_ext_y - 2 * epaisseur_paroi)\n", |
||||||
|
"\n", |
||||||
|
" extrude(amount=-emboitement_profondeur, mode=Mode.SUBTRACT)\n", |
||||||
|
"\n", |
||||||
|
" with BuildSketch(top_face) as sk:\n", |
||||||
|
" # Position relative au centre de la face (origine du sketch)\n", |
||||||
|
" with Locations(Location((0, 0))):\n", |
||||||
|
" Rectangle(bac_ext_x - 3 * epaisseur_paroi, bac_ext_y - 3 * epaisseur_paroi)\n", |
||||||
|
"\n", |
||||||
|
" extrude(amount=-(bac_hauteur - epaisseur_paroi), mode=Mode.SUBTRACT)\n", |
||||||
|
"\n", |
||||||
|
" return p.part\n", |
||||||
|
"\n", |
||||||
|
"\n", |
||||||
|
"# ─────────────────────────────────────────────────────────────────────────────\n", |
||||||
|
"# COUVERCLE\n", |
||||||
|
"# ─────────────────────────────────────────────────────────────────────────────\n", |
||||||
|
"\n", |
||||||
|
"def make_couvercle():\n", |
||||||
|
" with BuildPart() as p:\n", |
||||||
|
" # 1. Bloc de base\n", |
||||||
|
" Box(couv_ext_x, couv_ext_y, couv_ext_z)\n", |
||||||
|
"\n", |
||||||
|
" # 2. Évidement intérieur (lèvre qui coiffe le chapeau)\n", |
||||||
|
" with Locations(Location((0, 0, - emboitement_profondeur))):\n", |
||||||
|
" Box(\n", |
||||||
|
" couv_ext_x - 2 * epaisseur_paroi,\n", |
||||||
|
" couv_ext_y - 2 * epaisseur_paroi,\n", |
||||||
|
" emboitement_profondeur + 1,\n", |
||||||
|
" mode=Mode.SUBTRACT,\n", |
||||||
|
" )\n", |
||||||
|
"\n", |
||||||
|
" # 3. Ouverture rectangulaire centrée sur la cavité\n", |
||||||
|
" top_face = faces().sort_by(Axis.Z)[-1]\n", |
||||||
|
" with BuildSketch(top_face) as sk:\n", |
||||||
|
" # Position relative au centre de la face (origine du sketch)\n", |
||||||
|
" with Locations(Location((cav_x + cav_dim_x / 2 - bloc_extrudeur_ext_x / 2, 0))):\n", |
||||||
|
" Rectangle(couvercle_ouv_largeur, couvercle_ouv_profondeur)\n", |
||||||
|
" extrude(amount=-epaisseur_paroi* 2, mode=Mode.SUBTRACT)\n", |
||||||
|
"\n", |
||||||
|
" return p.part\n", |
||||||
|
"\n", |
||||||
|
"\n", |
||||||
|
"def center_xy(part):\n", |
||||||
|
" bb = part.bounding_box()\n", |
||||||
|
" return part.translate((-bb.center().X, -bb.center().Y, 0))\n", |
||||||
|
"\n", |
||||||
|
"\n", |
||||||
|
"gap = 50\n", |
||||||
|
"\n", |
||||||
|
"show(\n", |
||||||
|
" center_xy(make_bloc_extrudeur()),\n", |
||||||
|
" center_xy(make_bac_recup()).translate((0, 0, -(bloc_extrudeur_ext_z / 2 + 2 * gap))),\n", |
||||||
|
" center_xy(make_couvercle()).translate((0, 0, bloc_extrudeur_ext_z / 2 + gap)),\n", |
||||||
|
" names=[\"superieure\", \"inferieure\", \"couvercle\"],\n", |
||||||
|
" colors=[\"#ff7800\", \"#000000\", \"#000000\"],\n", |
||||||
|
")" |
||||||
|
], |
||||||
|
"outputs": [ |
||||||
|
{ |
||||||
|
"name": "stdout", |
||||||
|
"output_type": "stream", |
||||||
|
"text": [ |
||||||
|
"+c+\n" |
||||||
|
] |
||||||
|
} |
||||||
|
], |
||||||
|
"execution_count": 87 |
||||||
|
}, |
||||||
|
{ |
||||||
|
"metadata": { |
||||||
|
"ExecuteTime": { |
||||||
|
"end_time": "2026-05-09T00:48:40.405653163Z", |
||||||
|
"start_time": "2026-05-09T00:48:40.393920716Z" |
||||||
|
} |
||||||
|
}, |
||||||
|
"cell_type": "code", |
||||||
|
"source": "tract_extrusion_center_x_offset", |
||||||
|
"id": "810fb3a101c2fccd", |
||||||
|
"outputs": [ |
||||||
|
{ |
||||||
|
"data": { |
||||||
|
"text/plain": [ |
||||||
|
"32.5" |
||||||
|
] |
||||||
|
}, |
||||||
|
"execution_count": 64, |
||||||
|
"metadata": {}, |
||||||
|
"output_type": "execute_result" |
||||||
|
} |
||||||
|
], |
||||||
|
"execution_count": 64 |
||||||
|
} |
||||||
|
], |
||||||
|
"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