Dalsze Prace nad gridem i szczebelkami

This commit is contained in:
Rafal 2025-06-07 17:34:25 +00:00
parent 1505f300e0
commit 1fda2a11ed
17 changed files with 61367 additions and 128 deletions

View File

@ -2,23 +2,17 @@
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 71,
"id": "0a626b10-f8c1-4fa1-a186-71d6f989e162",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Overwriting auto display for cadquery Workplane and Shape\n",
"Overwriting auto display for build123d BuildPart, BuildSketch, BuildLine, ShapeList\n"
]
}
],
"outputs": [],
"source": [
"from build123d import *\n",
"\n",
"from jupyter_cadquery import show, show_all,open_viewer"
"from jupyter_cadquery import show, show_all,open_viewer, show_clear\n",
"\n",
"from IPython.display import display\n",
"import ipywidgets as widgets"
]
},
{
@ -28,7 +22,7 @@
"metadata": {},
"outputs": [],
"source": [
"# cv = open_viewer(\"Build123d\", anchor=\"split-bottom\",aspect_ratio=3/4)"
"#cv = open_viewer(\"Build123d\", anchor=\"split-bottom\")"
]
},
{
@ -38,12 +32,108 @@
"metadata": {},
"outputs": [],
"source": [
"cv = open_viewer(\"Build123d\", anchor=\"right\")"
"#cv = open_viewer(\"Build123d\", anchor=\"right\")"
]
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 73,
"id": "fadf9175-fa62-4758-b8df-8da736b62990",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "88ca83c276564176aa843f956498a2c9",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"HBox(children=(Button(description='Viewer dół', style=ButtonStyle()), Button(description='Viewer prawo', style…"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"cv = None # viewer globalny\n",
"\n",
"def open_bottom(b):\n",
" global cv\n",
" print(\"Otwieram viewer (split-bottom)\")\n",
" cv = open_viewer(\"Build123d\", anchor=\"split-bottom\")\n",
"\n",
"def open_right(b):\n",
" global cv\n",
" print(\"Otwieram viewer (right)\")\n",
" cv = open_viewer(\"Build123d\", anchor=\"right\")\n",
"\n",
"# Przycisk 1 bottom\n",
"btn_bottom = widgets.Button(description=\"Viewer dół\")\n",
"btn_bottom.on_click(open_bottom)\n",
"\n",
"# Przycisk 2 right\n",
"btn_right = widgets.Button(description=\"Viewer prawo\")\n",
"btn_right.on_click(open_right)\n",
"\n",
"# Wyświetl przyciski\n",
"display(widgets.HBox([btn_bottom, btn_right]))\n"
]
},
{
"cell_type": "code",
"execution_count": 45,
"id": "177fa70e-22e7-4c1e-823f-faf4b807a78c",
"metadata": {},
"outputs": [],
"source": [
"comet_up = import_step(\"/home/workdir/Camper/cometup.step\")\n",
"comet_down = import_step(\"/home/workdir/Camper/cometdown.step\")\n",
"comet_up.color = Color(117/255,117/255,117/255)\n",
"comet_down.color = Color(117/255,117/255,117/255)\n",
"okranik = comet_up.move(Location((-1165.250-130,150+30,546.500-24),((0,0,-0))))\n",
"zkranik = comet_down.move(Location((-1165.250-130,150+30,546.500-24),((0,0,-0))))\n"
]
},
{
"cell_type": "code",
"execution_count": 66,
"id": "b7afe8de-f86e-4a84-91c2-1321d247f20e",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "4478a79aadec4062b1de03595ea21780",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Button(description='open/closed', style=ButtonStyle())"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"podnies_karnister = False\n",
"otwarta_szuflada = True\n",
"\n",
"# Funkcja przełączająca wartość\n",
"def toggle_szuflada(change):\n",
" global otwarta_szuflada\n",
" otwarta_szuflada = not otwarta_szuflada\n",
"\n",
"button = widgets.Button(description=\"open/closed\")\n",
"button.on_click(toggle_szuflada)\n",
"display(button)"
]
},
{
"cell_type": "code",
"execution_count": 72,
"id": "0859af03-2222-4b9d-b6fe-04bbc2794516",
"metadata": {},
"outputs": [
@ -51,27 +141,11 @@
"name": "stdout",
"output_type": "stream",
"text": [
"+cc\n"
"cccccccc\n"
]
},
{
"data": {
"text/plain": [
"<cad_viewer_widget.widget.CadViewer at 0x145d5e4e4ec0>"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"from build123d import *\n",
"from ocp_vscode import show\n",
"\n",
"\n",
"podnies_karnister = False\n",
"otwarta_szuflada = False\n",
"\n",
"\n",
"\n",
@ -82,6 +156,7 @@
"profil = 40\n",
"profil_8040 = 80 \n",
"sklejka = 15\n",
"prowadnica = 19\n",
"\n",
"# Wymiary karnistra\n",
"dl_k = 360\n",
@ -94,14 +169,22 @@
"sz_sz = sz - (2*profil)\n",
"wys_sz = wys - profil\n",
"\n",
"# wymiary zlewu\n",
"\n",
"dl_z = 320\n",
"sz_z = 260\n",
"wys_z = 150\n",
"odstep_zlewu_od_konca = 260\n",
"\n",
"dl_sklejki = dl-dl_sz\n",
"\n",
"\n",
"\n",
"with BuildPart() as szkielet:\n",
" with Locations((0,-sz/2 + profil/2,0)):\n",
" # Poziome\n",
" with Locations((0, 0, 0), (0, sz - profil, 0)):\n",
" Box(dl-(2*profil), profil, profil)\n",
" with Locations((0, 0, profil/2), (0, sz - profil, profil/2)):\n",
" Box(dl-(2*profil), profil, profil_8040)\n",
" with Locations((0, 0, wys - profil), (0, sz - profil, wys - profil)):\n",
" Box(dl-(2*profil), profil, profil)\n",
" # Pionowe\n",
@ -136,25 +219,87 @@
"else:\n",
" szuflada_stan = (-dl/2+dl_sz/2,0,wys/2-profil+15)\n",
" \n",
"\n",
"with BuildPart() as wyciecie:\n",
" with Locations(szuflada_stan):\n",
" with Locations((dl_sz/2 - sz_z/2 - odstep_zlewu_od_konca ,0,wys_sz/2-wys_z/2-sklejka/2+1)):\n",
" Box(sz_z,dl_z,wys_z)\n",
" to_edges = wyciecie.edges().filter_by(Axis.Z)\n",
" fillet(to_edges,radius=20)\n",
"\n",
"with BuildPart() as szuflada:\n",
" with Locations(szuflada_stan):\n",
" Box(dl_sz,sz_sz,wys_sz)\n",
" offset(amount=-15, openings=szuflada.faces().sort_by(Axis.Z)[-1])\n",
"\n",
" Box(dl_sz,sz_sz-(2*prowadnica),wys_sz)\n",
" offset(amount=-15, openings=szuflada.faces().filter_by(Axis.Z)[-1])\n",
" if otwarta_szuflada == True:\n",
" with Locations((-dl_sz/4,45.960,wys_sz/2+154.68)):\n",
" Box(dl_sz/2,sz_sz-2*prowadnica,sklejka, rotation=(-45,0,0))\n",
" with Locations((dl_sz/4,0,wys_sz/2)):\n",
" Box(dl_sz/2,sz_sz-2*prowadnica,sklejka)\n",
" else: \n",
" with Locations((-dl_sz/4,0,wys_sz/2)):\n",
" Box(dl_sz/2,sz_sz-2*prowadnica,sklejka)\n",
" with Locations((dl_sz/4,0,wys_sz/2)):\n",
" Box(dl_sz/2,sz_sz-2*prowadnica,sklejka)\n",
" with Locations((0,0,sklejka)):\n",
" add(wyciecie,mode=Mode.SUBTRACT)\n",
" \n",
"show_all()\n",
"# show(szuflada)"
" \n",
"\n",
"\n",
"with BuildPart() as zlew:\n",
" with Locations(szuflada_stan):\n",
" with Locations((dl_sz/2 - sz_z/2 - odstep_zlewu_od_konca ,0,wys_sz/2-wys_z/2-sklejka/2+sklejka)):\n",
" Box(sz_z,dl_z,wys_z)\n",
" # with Locations(zlew.faces().last):\n",
" # Hole(10)\n",
" offset(amount=-10,openings=zlew.part.faces().filter_by(Axis.Z)[-1])\n",
" test = zlew.faces().last\n",
" with Locations((0,0,0)):\n",
" Hole(20)\n",
" to_edges = zlew.edges().filter_by(Axis.Z)\n",
" fillet(to_edges,radius=10)\n",
"\n",
" zlew.color = Color(114/255,114/255,114/255)\n",
"\n",
"# comet_up.move(Location((szuflada_stan)))\n",
" \n",
"\n",
"\n",
"# render_part(my_part.part) # jeśli używasz jupyter + ocp_vscode\n",
" \n",
"\n",
"\n",
"# show(szuflada)\n",
"# show_all()\n",
"if otwarta_szuflada == True:\n",
" show(szkielet,szuflada,karnister,zlew,okranik)\n",
"else:\n",
" show(szkielet,szuflada,karnister,zlew,zkranik)\n",
"# show(comet_up)\n",
"# show(zlew,test)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "f1917c8d-bfa7-4cf4-ad99-541eb07ce594",
"id": "96345b66-b36c-477d-8929-eebee31d89ed",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"id": "a6ee791b-7852-4eda-b268-889766967eb2",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"id": "141cbaf3-fdda-47ad-9409-0a28455c1d13",
"metadata": {},
"source": []
}
],
"metadata": {

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,32 @@
from IPython.display import display
from IPython import get_ipython
import ipywidgets as widgets
snippets = {
"📥 Start": '''
from build123d import *
from jupyter_cadquery import show, show_all,open_viewer, show_clear
from IPython.display import display
import ipywidgets as widgets''',
"🧲 Import STEP": '''from build123d import *
model = import_step("element.step")
show_object(model)''',
"🧪 Cylinder": '''from build123d import *
Cylinder(30, 80)'''
}
dropdown = widgets.Dropdown(
options=["-- wybierz snippet --"] + list(snippets.keys()),
description="Snippet:"
)
def on_select(change):
key = change["new"]
if key != "-- wybierz snippet --":
get_ipython().set_next_input(snippets[key], replace=False)
dropdown.value = "-- wybierz snippet --"
dropdown.observe(on_select, names="value")
display(dropdown)

View File

@ -0,0 +1,55 @@
from IPython.display import display
from IPython import get_ipython
import ipywidgets as widgets
def show_snippet_panel():
snippets = {
"📥 Start": '''
from build123d import *
from jupyter_cadquery import show, show_all,open_viewer, show_clear
from IPython.display import display
import ipywidgets as widgets''',
"🧲 Import STEP": '''from build123d import *
model = import_step("element.step")
show_object(model)''',
"🖥️ view": '''
cv = None # viewer globalny
def open_bottom(b):
global cv
print("Otwieram viewer (split-bottom)")
cv = open_viewer("Build123d", anchor="split-bottom")
def open_right(b):
global cv
print("Otwieram viewer (right)")
cv = open_viewer("Build123d", anchor="right")
# Przycisk 1 bottom
btn_bottom = widgets.Button(description="Viewer dół")
btn_bottom.on_click(open_bottom)
# Przycisk 2 right
btn_right = widgets.Button(description="Viewer prawo")
btn_right.on_click(open_right)
# Wyświetl przyciski
display(widgets.HBox([btn_bottom, btn_right]))
'''
}
dropdown = widgets.Dropdown(
options=["-- wybierz snippet --"] + list(snippets.keys()),
description="Snippet:"
)
def on_select(change):
key = change["new"]
if key != "-- wybierz snippet --":
get_ipython().set_next_input(snippets[key], replace=False)
dropdown.value = "-- wybierz snippet --"
dropdown.observe(on_select, names="value")
display(dropdown)

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,6 @@
{
"cells": [],
"metadata": {},
"nbformat": 4,
"nbformat_minor": 5
}

View File

@ -20,15 +20,46 @@
"\n",
"from jupyter_cadquery import show, show_all,open_viewer, show_clear\n",
"\n",
"from hinge import Hinge\n",
"\n"
"from IPython.display import display\n",
"import ipywidgets as widgets\n",
"\n",
"from snippets_panel import show_snippet_panel"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "67a54d02-2fd4-4f9a-8391-64e8617a5aef",
"id": "51e61e11-473c-492c-9b2b-4504dadfa938",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "5edd1cdb172b42abb9247da9bd5e859e",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Dropdown(description='Snippet:', options=('-- wybierz snippet --', '📥 Start', '🧲 Import STEP', '🖥️ view'), val…"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"show_snippet_panel()"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "67a54d02-2fd4-4f9a-8391-64e8617a5aef",
"metadata": {
"jupyter": {
"source_hidden": true
}
},
"outputs": [],
"source": [
"#cv = open_viewer(\"Build123d\", anchor=\"split-bottom\")"
@ -36,17 +67,123 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 4,
"id": "cd726fcd-9dea-4a0d-9710-519b45a58f88",
"metadata": {},
"outputs": [],
"source": [
"cv = open_viewer(\"Build123d\", anchor=\"right\")"
"#cv = open_viewer(\"Build123d\", anchor=\"right\")"
]
},
{
"cell_type": "code",
"execution_count": 33,
"execution_count": 5,
"id": "8521687b-c556-461d-b0ff-4d861806a762",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "e4759fe05e6641bd838a1d77bd76e614",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"HBox(children=(Button(description='Viewer dół', style=ButtonStyle()), Button(description='Viewer prawo', style…"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
" \n",
"cv = None # viewer globalny\n",
"\n",
"def open_bottom(b):\n",
" global cv\n",
" print(\"Otwieram viewer (split-bottom)\")\n",
" cv = open_viewer(\"Build123d\", anchor=\"split-bottom\")\n",
"\n",
"def open_right(b):\n",
" global cv\n",
" print(\"Otwieram viewer (right)\")\n",
" cv = open_viewer(\"Build123d\", anchor=\"right\")\n",
"\n",
"# Przycisk 1 bottom\n",
"btn_bottom = widgets.Button(description=\"Viewer dół\")\n",
"btn_bottom.on_click(open_bottom)\n",
"\n",
"# Przycisk 2 right\n",
"btn_right = widgets.Button(description=\"Viewer prawo\")\n",
"btn_right.on_click(open_right)\n",
"\n",
"# Wyświetl przyciski\n",
"display(widgets.HBox([btn_bottom, btn_right]))\n",
" "
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "b7afe8de-f86e-4a84-91c2-1321d247f20e",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "cd3fbdb82a2648078f14548d5df544c7",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Button(description='open/closed', style=ButtonStyle())"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"podnies_karnister = False\n",
"otwarta_szuflada = True\n",
"\n",
"# Funkcja przełączająca wartość\n",
"def toggle_szuflada(change):\n",
" global otwarta_szuflada\n",
" otwarta_szuflada = not otwarta_szuflada\n",
"\n",
"button = widgets.Button(description=\"open/closed\")\n",
"button.on_click(toggle_szuflada)\n",
"display(button)"
]
},
{
"cell_type": "code",
"execution_count": 105,
"id": "177fa70e-22e7-4c1e-823f-faf4b807a78c",
"metadata": {},
"outputs": [],
"source": [
"comet_up = import_step(\"./cometup.step\")\n",
"comet_down = import_step(\"./cometdown.step\")\n",
"comet_up.color = Color(117/255,117/255,117/255)\n",
"comet_down.color = Color(117/255,117/255,117/255)\n",
"okranik = comet_up.move(Location((-1165.250-130,150+30,546.500-24-17.50-7.5),((0,0,-0))))\n",
"zkranik = comet_down.move(Location((-1165.250-130+1100,150+30,546.500-24-17.50-7.5),((0,0,-0))))\n",
"\n",
"# zawias = import_step(\"./zawias.step\")\n",
"# zawias.color = Color(\"black\")\n",
"\n",
"# zawias1 = import_step(\"./hinge1.STEP\")\n",
"# zawias1 = zawias1.move(Location((-80/4,0,wys+6.3),(90,90,0)))\n",
"# zawias2 = import_step(\"./hinge2.STEP\")\n",
"# zawias2 = zawias2.move(Location((-80/4,26+4,wys+10-0.5),(90,90,180)))\n"
]
},
{
"cell_type": "code",
"execution_count": 142,
"id": "0859af03-2222-4b9d-b6fe-04bbc2794516",
"metadata": {},
"outputs": [
@ -54,31 +191,19 @@
"name": "stdout",
"output_type": "stream",
"text": [
"+\n"
"cccccccc+\n"
]
},
{
"data": {
"text/plain": [
"<cad_viewer_widget.widget.CadViewer at 0x1534a50d6d80>"
]
},
"execution_count": 33,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"podnies_karnister = False\n",
"otwarta_szuflada = True\n",
"\n",
"\n",
"# Wymiary szkieletu boxa (mm)\n",
"dl = 1810.5\n",
"\n",
"dl = 1800\n",
"sz = 570.5\n",
"wys = 560\n",
"profil = 40\n",
"profil_8040 = 80 \n",
"profil = 30\n",
"profil_3060 = 60 \n",
"sklejka = 15\n",
"prowadnica = 19\n",
"\n",
@ -91,7 +216,7 @@
"# Wymiary Skrzyni\n",
"dl_sz = 1100\n",
"sz_sz = sz - (2*profil)\n",
"wys_sz = wys - profil\n",
"wys_sz = wys - profil - 50\n",
"\n",
"# wymiary zlewu\n",
"\n",
@ -101,13 +226,14 @@
"odstep_zlewu_od_konca = 260\n",
"\n",
"dl_sklejki = dl-dl_sz\n",
"deska = 80\n",
"\n",
"\n",
"with BuildPart() as szkielet:\n",
" with Locations((0,-sz/2 + profil/2,0)):\n",
" # Poziome\n",
" with Locations((0, 0, profil/2), (0, sz - profil, profil/2)):\n",
" Box(dl-(2*profil), profil, profil_8040)\n",
" Box(dl-(2*profil), profil, 60)\n",
" with Locations((0, 0, wys - profil), (0, sz - profil, wys - profil)):\n",
" Box(dl-(2*profil), profil, profil)\n",
" # Pionowe\n",
@ -123,6 +249,8 @@
" Box(dl_sklejki,sz,sklejka)\n",
"\n",
"\n",
"szkielet.color = Color(178/255,178/255,178/255)\n",
"\n",
"\n",
"if podnies_karnister == True:\n",
" podnies_karnister = 600\n",
@ -138,25 +266,10 @@
"\n",
"\n",
"if otwarta_szuflada == True:\n",
" szuflada_stan = (-dl/2+dl_sz/2-dl_sz,0,wys/2-profil+15)\n",
" szuflada_stan = (-dl/2+dl_sz/2-dl_sz,0,wys/2-profil)\n",
"else:\n",
" szuflada_stan = (-dl/2+dl_sz/2,0,wys/2-profil+15)\n",
" szuflada_stan = (-dl/2+dl_sz/2,0,wys/2-profil)\n",
" \n",
"\n",
"with BuildPart() as szuflada:\n",
" with Locations(szuflada_stan):\n",
" Box(dl_sz,sz_sz-(2*prowadnica),wys_sz)\n",
" offset(amount=-15, openings=szuflada.faces().filter_by(Axis.Z)[-1])\n",
" if otwarta_szuflada == True:\n",
" with Locations((-dl_sz/4,45.960,wys_sz/2+154.68)):\n",
" Box(dl_sz/2,sz_sz-2*prowadnica,sklejka, rotation=(-45,0,0))\n",
" else: \n",
" with Locations((-dl_sz/4,0,wys_sz/2)):\n",
" Box(dl_sz/2,sz_sz-2*prowadnica,sklejka)\n",
" \n",
" with Locations((dl_sz/4,0,wys_sz/2)):\n",
" Box(dl_sz/2,sz_sz-2*prowadnica,sklejka)\n",
" \n",
"with BuildPart() as wyciecie:\n",
" with Locations(szuflada_stan):\n",
" with Locations((dl_sz/2 - sz_z/2 - odstep_zlewu_od_konca ,0,wys_sz/2-wys_z/2-sklejka/2+1)):\n",
@ -164,71 +277,72 @@
" to_edges = wyciecie.edges().filter_by(Axis.Z)\n",
" fillet(to_edges,radius=20)\n",
"\n",
"with BuildPart() as szuflada:\n",
" with Locations(szuflada_stan):\n",
" Box(dl_sz,sz_sz-(2*prowadnica),wys_sz)\n",
" offset(amount=-15, openings=szuflada.faces().filter_by(Axis.Z)[-1])\n",
" if otwarta_szuflada == True:\n",
" with Locations((-dl_sz/4,74.5,wys_sz/2+200-27.64)):\n",
" Box(dl_sz/2,sz_sz-2*prowadnica,sklejka, rotation=(-45,0,0))\n",
" with Locations((dl_sz/4,0,wys_sz/2)):\n",
" Box(dl_sz/2,sz_sz-2*prowadnica,sklejka)\n",
" else: \n",
" with Locations((-dl_sz/4,0,wys_sz/2)):\n",
" Box(dl_sz/2,sz_sz-2*prowadnica,sklejka)\n",
" with Locations((dl_sz/4,0,wys_sz/2)):\n",
" Box(dl_sz/2,sz_sz-2*prowadnica,sklejka)\n",
" with Locations((0,0,20)):\n",
" add(wyciecie,mode=Mode.SUBTRACT)\n",
" \n",
" \n",
"\n",
"\n",
"with BuildPart() as zlew:\n",
" with Locations(szuflada_stan):\n",
" with Locations((dl_sz/2 - sz_z/2 - odstep_zlewu_od_konca ,0,wys_sz/2-wys_z/2-sklejka/2+1)):\n",
" with Locations((dl_sz/2 - sz_z/2 - odstep_zlewu_od_konca ,0,wys_sz/2-wys_z/2-sklejka/2+sklejka)):\n",
" Box(sz_z,dl_z,wys_z)\n",
" # with Locations(zlew.faces().last):\n",
" # Hole(10)\n",
" offset(amount=-10,openings=zlew.part.faces().filter_by(Axis.Z)[-1])\n",
" test = zlew.faces().last\n",
" with Locations((0,dl_z/2-50,0)):\n",
" with Locations((0,0,0)):\n",
" Hole(20)\n",
" to_edges = zlew.edges().filter_by(Axis.Z)\n",
" fillet(to_edges,radius=10)\n",
"\n",
" zlew.color = Color(114/255,114/255,114/255)\n",
"\n",
"\n",
"\n",
"with BuildPart() as razem:\n",
" add(szkielet)\n",
" add(szuflada)\n",
" add(karnister)\n",
" with Locations((0,0,sklejka)):\n",
" add(wyciecie,mode=Mode.SUBTRACT)\n",
" add(zlew)\n",
"\n",
"\n",
"\n",
"# with BuildPart() as model:\n",
"# add(Hinge(20, 40, 6, 2, 3,False))\n",
"\n",
"# show(model.part)\n",
"\n",
"# comet_up.move(Location((szuflada_stan)))\n",
" \n",
"\n",
"\n",
"# render_part(my_part.part) # jeśli używasz jupyter + ocp_vscode\n",
" \n",
"\n",
"with BuildPart() as zabudowa_bed:\n",
" with Locations((0,sz/2-10,wys-5)):\n",
" Box(dl,20,20)\n",
" with Locations((0,-10,wys-5)):\n",
" with GridLocations(300,0,6,1):\n",
" Box(deska,sz-20,20)\n",
" with Locations((0,-10,wys-5)):\n",
" with GridLocations(300,0,5,1):\n",
" Box(deska,sz-20,20)\n",
"\n",
"\n",
"# show(szuflada)\n",
"# show(szuflada,wyciecie)\n",
"# show(zlew)\n",
"# show_all()\n",
"show(razem)\n",
"# show(zlew,test)"
"if otwarta_szuflada == True:\n",
" show(szkielet,szuflada,karnister,zlew,okranik,zabudowa_bed)\n",
"else:\n",
" show(szkielet,szuflada,karnister,zlew,zkranik,zabudowa_bed)\n",
"\n",
"# show(comet_up)\n",
"#\n",
"# show(szkielet)\n",
"# show(zawias2)\n",
"# export_step(szkielet.part,\"./szkielet.step\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "96345b66-b36c-477d-8929-eebee31d89ed",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"id": "a6ee791b-7852-4eda-b268-889766967eb2",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"id": "141cbaf3-fdda-47ad-9409-0a28455c1d13",
"metadata": {},
"source": []
}
],
"metadata": {

Binary file not shown.

Binary file not shown.

Binary file not shown.

17950
cometdown.step Normal file

File diff suppressed because it is too large Load Diff

17950
cometup.step Normal file

File diff suppressed because it is too large Load Diff

1176
hinge1.STEP Normal file

File diff suppressed because it is too large Load Diff

1176
hinge2.STEP Normal file

File diff suppressed because it is too large Load Diff

1
snippets_panel.py Symbolic link
View File

@ -0,0 +1 @@
/home/workdir/Snippets/snippets_panel.py

2217
szkielet.step Normal file

File diff suppressed because it is too large Load Diff

250
testy.ipynb Normal file
View File

@ -0,0 +1,250 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 3,
"id": "d3c7da8b-6cb5-4f1c-8f89-f7f07742c08b",
"metadata": {},
"outputs": [],
"source": [
"from snippets_panel import show_snippet_panel"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "6b9e7de0-66d6-49cd-8935-c8dd3fcca18d",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "d03f993365f64ff7bbbfb3b47955476f",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Dropdown(description='Snippet:', options=('-- wybierz snippet --', '📥 Start', '🧲 Import STEP', '🖥️ view'), val…"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"show_snippet_panel()"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "2a686127-10fb-46ca-a1bf-463060dbadf5",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Overwriting auto display for cadquery Workplane and Shape\n",
"Overwriting auto display for build123d BuildPart, BuildSketch, BuildLine, ShapeList\n"
]
}
],
"source": [
"\n",
"from build123d import *\n",
"from jupyter_cadquery import show, show_all,open_viewer, show_clear\n",
"from IPython.display import display\n",
"import ipywidgets as widgets"
]
},
{
"cell_type": "code",
"execution_count": 18,
"id": "b862c8ca-ecc7-4ea8-a26d-1cf2f5a08f23",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "6f1460081e7842b195ccebf7c1f0306d",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"HBox(children=(Button(description='Viewer dół', style=ButtonStyle()), Button(description='Viewer prawo', style…"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
" \n",
"cv = None # viewer globalny\n",
"\n",
"def open_bottom(b):\n",
" global cv\n",
" print(\"Otwieram viewer (split-bottom)\")\n",
" cv = open_viewer(\"Build123d\", anchor=\"split-bottom\")\n",
"\n",
"def open_right(b):\n",
" global cv\n",
" print(\"Otwieram viewer (right)\")\n",
" cv = open_viewer(\"Build123d\", anchor=\"right\")\n",
"\n",
"# Przycisk 1 bottom\n",
"btn_bottom = widgets.Button(description=\"Viewer dół\")\n",
"btn_bottom.on_click(open_bottom)\n",
"\n",
"# Przycisk 2 right\n",
"btn_right = widgets.Button(description=\"Viewer prawo\")\n",
"btn_right.on_click(open_right)\n",
"\n",
"# Wyświetl przyciski\n",
"display(widgets.HBox([btn_bottom, btn_right]))\n",
" "
]
},
{
"cell_type": "code",
"execution_count": 19,
"id": "530b84eb-9792-4117-bf83-cda7ab89c52e",
"metadata": {},
"outputs": [
{
"ename": "ValueError",
"evalue": "No objects to create a hull",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mValueError\u001b[0m Traceback (most recent call last)",
"Cell \u001b[0;32mIn[19], line 34\u001b[0m\n\u001b[1;32m 31\u001b[0m Circle(pin_diameter \u001b[38;5;241m/\u001b[39m \u001b[38;5;241m2\u001b[39m)\n\u001b[1;32m 32\u001b[0m \u001b[38;5;66;03m# Przesunięcie okręgu do odpowiedniej pozycji na skrzydle\u001b[39;00m\n\u001b[1;32m 33\u001b[0m \u001b[38;5;66;03m# Pozycja jest na środku długości, przy krawędzi szerokości\u001b[39;00m\n\u001b[0;32m---> 34\u001b[0m \u001b[43mmake_face\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 35\u001b[0m s\u001b[38;5;241m.\u001b[39mvertices()\u001b[38;5;241m.\u001b[39mfilter_by_position(Axis\u001b[38;5;241m.\u001b[39mX, hinge_leaf_width \u001b[38;5;241m/\u001b[39m \u001b[38;5;241m2\u001b[39m, tolerance\u001b[38;5;241m=\u001b[39m\u001b[38;5;241m0.1\u001b[39m)\u001b[38;5;241m.\u001b[39mmove(\n\u001b[1;32m 36\u001b[0m Location((hinge_leaf_width \u001b[38;5;241m/\u001b[39m \u001b[38;5;241m2\u001b[39m, \u001b[38;5;241m0\u001b[39m, \u001b[38;5;241m0\u001b[39m))\n\u001b[1;32m 37\u001b[0m )\n\u001b[1;32m 38\u001b[0m \u001b[38;5;66;03m# Wycięcie otworu przez całą grubość skrzydła\u001b[39;00m\n",
"File \u001b[0;32m/usr/local/lib/python3.12/site-packages/build123d/operations_sketch.py:217\u001b[0m, in \u001b[0;36mmake_face\u001b[0;34m(edges, mode)\u001b[0m\n\u001b[1;32m 215\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mValueError\u001b[39;00m(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mNo objects to create a face\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n\u001b[1;32m 216\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m outer_edges:\n\u001b[0;32m--> 217\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mValueError\u001b[39;00m(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mNo objects to create a hull\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n\u001b[1;32m 218\u001b[0m validate_inputs(context, \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mmake_face\u001b[39m\u001b[38;5;124m\"\u001b[39m, outer_edges)\n\u001b[1;32m 220\u001b[0m pending_face \u001b[38;5;241m=\u001b[39m Face(Wire\u001b[38;5;241m.\u001b[39mcombine(outer_edges)[\u001b[38;5;241m0\u001b[39m])\n",
"\u001b[0;31mValueError\u001b[0m: No objects to create a hull"
]
}
],
"source": [
"# Importowanie niezbędnych modułów z build123d\n",
"from build123d import *\n",
"\n",
"# Definicja wymiarów zawiasu\n",
"# Szerokość każdej \"skrzydła\" zawiasu (części mocowanej do drzwi/ramy)\n",
"hinge_leaf_width = 30\n",
"# Długość każdej skrzydła\n",
"hinge_leaf_length = 60\n",
"# Grubość skrzydła\n",
"hinge_leaf_thickness = 3\n",
"# Średnica trzpienia (oś obrotu zawiasu)\n",
"pin_diameter = 4\n",
"# Długość trzpienia (nieco dłuższy niż całkowita długość segmentów zawiasu)\n",
"pin_length = hinge_leaf_length * 1.05\n",
"# Promień zaokrąglenia na krawędziach\n",
"radius = 1\n",
"\n",
"# Tworzenie pierwszej \"skrzydła\" zawiasu\n",
"with BuildPart() as hinge_leaf1:\n",
" # Szkic prostokąta, który będzie podstawą skrzydła\n",
" with BuildSketch() as s:\n",
" Rectangle(hinge_leaf_width, hinge_leaf_length)\n",
" # Zaokrąglenie rogów prostokąta\n",
" fillet(s.vertices(), radius)\n",
" # Wyciągnięcie szkicu, aby nadać mu grubość\n",
" extrude(amount=hinge_leaf_thickness)\n",
"\n",
" # Tworzenie otworu na trzpień w pierwszej skrzydle\n",
" with BuildSketch(Plane.XZ) as s:\n",
" # Rysowanie okręgu, który będzie otworem\n",
" Circle(pin_diameter / 2)\n",
" # Przesunięcie okręgu do odpowiedniej pozycji na skrzydle\n",
" # Pozycja jest na środku długości, przy krawędzi szerokości\n",
" make_face()\n",
" s.vertices().filter_by_position(Axis.X, hinge_leaf_width / 2, tolerance=0.1).move(\n",
" Location((hinge_leaf_width / 2, 0, 0))\n",
" )\n",
" # Wycięcie otworu przez całą grubość skrzydła\n",
" extrude(amount=-hinge_leaf_thickness, mode=Mode.SUBTRACT)\n",
"\n",
"# Tworzenie drugiej \"skrzydła\" zawiasu\n",
"# Jest identyczna jak pierwsza, więc możemy ją skopiować\n",
"hinge_leaf2 = hinge_leaf1.part.copy()\n",
"\n",
"# Tworzenie trzpienia zawiasu\n",
"with BuildPart() as pin:\n",
" # Szkic okręgu, który będzie podstawą trzpienia\n",
" with BuildSketch() as s:\n",
" Circle(pin_diameter / 2)\n",
" # Wyciągnięcie szkicu, aby nadać mu długość\n",
" extrude(amount=pin_length)\n",
"\n",
"# Montaż zawiasu\n",
"with BuildPart() as hinge_assembly:\n",
" # Dodanie pierwszej skrzydła do złożenia\n",
" add(hinge_leaf1.part)\n",
"\n",
" # Dodanie drugiej skrzydła\n",
" # Przesunięcie jej tak, aby była obok pierwszej, ale z odstępem na trzpień\n",
" # i obrócona o 180 stopni wokół osi Y, aby symulować złożenie zawiasu\n",
" add(hinge_leaf2, Location((0, 0, hinge_leaf_thickness + pin_diameter), (0, 1, 0), 180))\n",
"\n",
" # Dodanie trzpienia\n",
" # Pozycjonowanie trzpienia w otworach skrzydeł\n",
" add(pin.part, Location((hinge_leaf_width / 2, 0, (hinge_leaf_thickness + pin_diameter) / 2)))\n",
"\n",
"# Opcjonalnie: wyświetlenie modelu (jeśli używasz środowiska z wizualizacją)\n",
"# show(hinge_assembly) # Odkomentuj, jeśli chcesz wizualizować w środowisku build123d\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": 13,
"id": "ee62118f-0893-4002-ac93-4e7b017ab335",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"+\n"
]
},
{
"data": {
"text/plain": [
"<cad_viewer_widget.widget.CadViewer at 0x1552b223e6c0>"
]
},
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"show(my_part) # Powinien pokazać złożenie my_part"
]
}
],
"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.12.10"
}
},
"nbformat": 4,
"nbformat_minor": 5
}