Browse Source

AJustement des dimensions

master
hadware 2 months ago
parent
commit
146e571fea
  1. 135
      tests.ipynb
  2. 54
      tractrudeuse_v2.ipynb

135
tests.ipynb

@ -11,7 +11,7 @@
}
},
"source": [
"from build123d import *\n",
"\n",
"from ocp_vscode import show\n",
"\n",
"\n",
@ -20,6 +20,7 @@
" Box(10, 30, 20)\n",
" return p.part\n",
"\n",
"\n",
"show(make_test())"
],
"outputs": [
@ -44,29 +45,32 @@
{
"metadata": {
"ExecuteTime": {
"end_time": "2026-05-12T15:43:51.244991561Z",
"start_time": "2026-05-12T15:43:51.223161624Z"
"end_time": "2026-05-12T19:20:08.027100644Z",
"start_time": "2026-05-12T19:20:07.828843337Z"
}
},
"cell_type": "code",
"source": [
"from build123d import *\n",
"from ocp_vscode import *\n",
"\n",
"vis_diam = 4 + 1\n",
"vis_ecrou_diam = 7 + 2\n",
"vis_longueur = 15\n",
"vis_ecrou_hauteur = 3.2 + 0.15\n",
"with BuildPart() as p:\n",
" Box(15, 15, vis_longueur)\n",
" top_face = faces().filter_by(Plane.XY).filter_by(Axis.Z)[-1]\n",
" with Locations(top_face) as sk:\n",
" # Position relative au centre de la face (origine du sketch)\n",
" Hole(radius=vis_diam / 2, depth=vis_longueur - 1)\n",
" with BuildSketch(Plane(top_face).offset(-10)) as sk:\n",
" RegularPolygon(radius=vis_ecrou_diam / 2, side_count=6)\n",
"\n",
" extrude(amount=-vis_ecrou_hauteur, mode=Mode.SUBTRACT)\n",
"\n",
"# Créer une face plate (exemple : un carré dans le plan XY)\n",
"box = Box(10, 10, 10)\n",
"face = box.faces().filter_by(Plane.YX).sort_by(Axis.Z)[0]\n",
"print(face.center())\n",
"print(\"Normal avant inversion :\", face.orientation) # Affiche le vecteur normal (ex: (0, 0, 1))\n",
"\n",
"# Inverser le vecteur normal\n",
"face_reversed = -face\n",
"print(\"Normal après inversion :\", face_reversed.orientation) # Affiche le vecteur normal inversé\n",
"\n",
"print(Plane(face))\n",
"print(Plane(face).reverse())\n",
"print(Plane.XY)\n",
"print(Plane.XY.reverse())\n",
"print(Plane.YX)"
"show(p.part)\n",
"export_stl(p.part, \"/tmp/test_ecrou.stl\")"
],
"id": "7450390859017a41",
"outputs": [
@ -74,18 +78,95 @@
"name": "stdout",
"output_type": "stream",
"text": [
"Vector(0, 0, -5)\n",
"Normal avant inversion : Vector(0, 0, 0)\n",
"Normal après inversion : Vector(0, 0, 0)\n",
"Plane(o=(0.00, 0.00, -5.00), x=(1.00, 0.00, 0.00), z=(-0.00, -0.00, -1.00))\n",
"Plane(o=(0.00, 0.00, -5.00), x=(1.00, 0.00, 0.00), z=(0.00, 0.00, 1.00))\n",
"Plane(o=(0.00, 0.00, 0.00), x=(1.00, 0.00, 0.00), z=(0.00, 0.00, 1.00))\n",
"Plane(o=(0.00, 0.00, 0.00), x=(1.00, 0.00, 0.00), z=(-0.00, -0.00, -1.00))\n",
"Plane(o=(0.00, 0.00, 0.00), x=(0.00, 1.00, 0.00), z=(0.00, 0.00, -1.00))\n"
"+\n"
]
},
{
"data": {
"text/plain": [
"True"
]
},
"execution_count": 23,
"metadata": {},
"output_type": "execute_result"
}
],
"execution_count": 23
},
{
"metadata": {
"ExecuteTime": {
"end_time": "2026-05-12T20:49:38.331665787Z",
"start_time": "2026-05-12T20:49:38.112592978Z"
}
},
"cell_type": "code",
"source": [
"from build123d import *\n",
"from ocp_vscode import *\n",
"\n",
"encoche_profondeur = 4\n",
"encoche_longueur = 20\n",
"encoche_largueur = 10 / 3\n",
"\n",
"with BuildPart() as p_top:\n",
" Box(30, 10, 10)\n",
" bottom_face = faces().filter_by(Plane.XY).sort_by(Axis.Z)[0]\n",
" bottom_plane = Plane(\n",
" origin=(0, 0, bottom_face.center().Z),\n",
" z_dir=(0, 0, 1)\n",
" )\n",
" with BuildSketch(bottom_plane):\n",
" Rectangle(encoche_longueur, encoche_largueur)\n",
" extrude(amount=encoche_profondeur, mode=Mode.SUBTRACT)\n",
"\n",
" top_edges = edges(Select.LAST).filter_by_position(Axis.Z,\n",
" minimum=bottom_plane.origin.Z + encoche_profondeur - 0.01,\n",
" maximum=bottom_plane.origin.Z + encoche_profondeur )\n",
" print(top_edges)\n",
" chamfer(top_edges, length=1)\n",
"\n",
"with BuildPart() as p_bottom:\n",
" Box(30, 10, 10)\n",
" top_face = faces().filter_by(Plane.XY).sort_by(Axis.Z)[-1]\n",
" top_plane = Plane(\n",
" origin=(0, 0, top_face.center().Z),\n",
" z_dir=(0, 0, 1)\n",
" )\n",
" with BuildSketch(top_plane):\n",
" Rectangle(encoche_longueur - 0.3, encoche_largueur - 0.3)\n",
" extrude(amount=encoche_profondeur - 0.3, mode=Mode.ADD)\n",
" top_edges = edges(Select.LAST).filter_by_position(Axis.Z, minimum=top_plane.origin.Z + encoche_profondeur / 2,\n",
" maximum=top_plane.origin.Z + encoche_profondeur * 2)\n",
" chamfer(top_edges, length=1)\n",
"\n",
"c = Compound(children=[p_top.part, p_bottom.part])\n",
"show(p_top, p_bottom)\n",
"export_step(c, \"/tmp/test_emboitement.step\")"
],
"id": "daba6eff56e1a97c",
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[<build123d.topology.one_d.Edge object at 0x7edf3047ded0>, <build123d.topology.one_d.Edge object at 0x7edf3047e2d0>, <build123d.topology.one_d.Edge object at 0x7edf3047f190>, <build123d.topology.one_d.Edge object at 0x7edf3047d510>]\n",
"c+\n"
]
},
{
"data": {
"text/plain": [
"True"
]
},
"execution_count": 48,
"metadata": {},
"output_type": "execute_result"
}
],
"execution_count": 13
"execution_count": 48
},
{
"metadata": {

54
tractrudeuse_v2.ipynb

@ -6,8 +6,8 @@
"metadata": {
"collapsed": true,
"ExecuteTime": {
"end_time": "2026-05-12T16:07:33.781803143Z",
"start_time": "2026-05-12T16:07:26.817563805Z"
"end_time": "2026-05-12T22:59:12.711790474Z",
"start_time": "2026-05-12T22:59:04.480803556Z"
}
},
"source": [
@ -77,10 +77,10 @@
"bac_hauteur = 100.0 # mm\n",
"\n",
"# Fixations couvercle\n",
"vis_diam = 4 + 0.1\n",
"vis_diam = 4 + 1\n",
"vis_longueur = 40\n",
"vis_profondeur_trou_bloc = vis_longueur - couvercle_epaisseur\n",
"vis_ecrou_diam = 7 + 0.15\n",
"vis_ecrou_diam = 7 + 2\n",
"vis_ecrou_hauteur = 3.2 + 0.15\n",
"\n",
"# Fixation couplage des deux sous-parties du bloc extrudeur\n",
@ -116,12 +116,12 @@
"cav_y = 0\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",
"bac_ext_x = bloc_extrudeur_ext_x + epaisseur_paroi + 2 * emboitement_jeu\n",
"bac_ext_y = bloc_extrudeur_ext_y + epaisseur_paroi + 2 * 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_x = bloc_extrudeur_ext_x + epaisseur_paroi + 2 * emboitement_jeu\n",
"couv_ext_y = bloc_extrudeur_ext_y + epaisseur_paroi + 2 * emboitement_jeu\n",
"couv_ext_z = couvercle_epaisseur + emboitement_profondeur\n",
"\n",
"offset_couv = epaisseur_paroi + emboitement_jeu\n",
@ -284,7 +284,7 @@
" y_offsets = (bloc_extrudeur_ext_y / 2 - epaisseur_paroi / 2,\n",
" -(bloc_extrudeur_ext_y / 2) + epaisseur_paroi / 2)\n",
" x_offsets = (bloc_extrudeur_ext_x / 2 - epaisseur_paroi * 2,\n",
" - bloc_extrudeur_ext_x / 2 + epaisseur_paroi * 2)\n",
" - bloc_extrudeur_ext_x / 2 + epaisseur_paroi * 3)\n",
" sockets_offsets = list(product(x_offsets, y_offsets))\n",
" with BuildPart() as p_top:\n",
" add(top)\n",
@ -297,6 +297,10 @@
" with Locations(sockets_offsets):\n",
" Rectangle(encoche_longueur, encoche_largueur)\n",
" extrude(amount=encoche_profondeur, mode=Mode.SUBTRACT)\n",
" top_edges = edges(Select.LAST).filter_by_position(Axis.Z,\n",
" minimum=bottom_plane.origin.Z + encoche_profondeur - 0.01,\n",
" maximum=bottom_plane.origin.Z + encoche_profondeur)\n",
" chamfer(top_edges, length=1)\n",
"\n",
" with BuildPart() as p_bottom:\n",
" add(bottom)\n",
@ -307,8 +311,8 @@
" )\n",
" with BuildSketch(top_plane):\n",
" with Locations(sockets_offsets):\n",
" Rectangle(encoche_longueur - 0.4, encoche_largueur - 0.4)\n",
" extrude(amount=encoche_profondeur - 0.2, mode=Mode.ADD)\n",
" Rectangle(encoche_longueur - 0.3, encoche_largueur - 0.3)\n",
" extrude(amount=encoche_profondeur - 0.3, mode=Mode.ADD)\n",
" top_edges = edges(Select.LAST).filter_by_position(Axis.Z, minimum=top_plane.origin.Z + encoche_profondeur / 2, maximum= top_plane.origin.Z + encoche_profondeur * 2)\n",
" chamfer(top_edges, length=1)\n",
"\n",
@ -333,14 +337,16 @@
" 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",
" Rectangle(bloc_extrudeur_ext_x + emboitement_jeu * 2,\n",
" bloc_extrudeur_ext_y + emboitement_jeu * 2)\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",
" Rectangle(bloc_extrudeur_ext_x - epaisseur_paroi /2,\n",
" bloc_extrudeur_ext_y - epaisseur_paroi /2)\n",
"\n",
" extrude(amount=-(bac_hauteur - epaisseur_paroi), mode=Mode.SUBTRACT)\n",
"\n",
@ -361,7 +367,8 @@
" with BuildSketch(bottom_face) as sk:\n",
" # Position relative au centre de la face (origine du sketch)\n",
" with Locations(Location((0, 0))):\n",
" Rectangle(couv_ext_x - 2 * epaisseur_paroi, couv_ext_y - 2 * epaisseur_paroi, )\n",
" Rectangle(bloc_extrudeur_ext_x + emboitement_jeu * 2,\n",
" bloc_extrudeur_ext_y + emboitement_jeu * 2)\n",
" extrude(amount=-emboitement_profondeur, mode=Mode.SUBTRACT)\n",
"\n",
" # 3. Ouverture rectangulaire centrée sur la cavité\n",
@ -400,35 +407,38 @@
"name": "stdout",
"output_type": "stream",
"text": [
"c+c+\n"
"++++\n"
]
}
],
"execution_count": 14
"execution_count": 19
},
{
"metadata": {
"ExecuteTime": {
"end_time": "2026-05-09T14:28:52.711328232Z",
"start_time": "2026-05-09T14:28:52.689567682Z"
"end_time": "2026-05-12T23:02:00.063069947Z",
"start_time": "2026-05-12T23:01:52.552843497Z"
}
},
"cell_type": "code",
"source": "make_brake_formed",
"source": [
"full = Compound(children=[make_couvercle(), make_bac_recup(), make_bloc_extrudeur()])\n",
"export_step(full, \"/tmp/tractotine.step\")"
],
"id": "810fb3a101c2fccd",
"outputs": [
{
"data": {
"text/plain": [
"234.5"
"True"
]
},
"execution_count": 111,
"execution_count": 20,
"metadata": {},
"output_type": "execute_result"
}
],
"execution_count": 111
"execution_count": 20
}
],
"metadata": {

Loading…
Cancel
Save