Dalsze Prace nad gridem i szczebelkami
This commit is contained in:
@@ -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": {
|
||||
|
||||
17950
.ipynb_checkpoints/cometup-checkpoint.step
Normal file
17950
.ipynb_checkpoints/cometup-checkpoint.step
Normal file
File diff suppressed because it is too large
Load Diff
32
.ipynb_checkpoints/snippet-checkpoint.py
Normal file
32
.ipynb_checkpoints/snippet-checkpoint.py
Normal 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)
|
||||
55
.ipynb_checkpoints/snippets_panel-checkpoint.py
Normal file
55
.ipynb_checkpoints/snippets_panel-checkpoint.py
Normal 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)
|
||||
2217
.ipynb_checkpoints/szkielet-checkpoint.step
Normal file
2217
.ipynb_checkpoints/szkielet-checkpoint.step
Normal file
File diff suppressed because it is too large
Load Diff
6
.ipynb_checkpoints/testy-checkpoint.ipynb
Normal file
6
.ipynb_checkpoints/testy-checkpoint.ipynb
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"cells": [],
|
||||
"metadata": {},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 5
|
||||
}
|
||||
Reference in New Issue
Block a user